Fix fread/fwrite failure check.