Fix error checking on fread()