check result of fread()