fix fseek & fwrite