check sync_fp before calling fclose().