Use err_fread_noeof() instead of fread().