Check return value of fread call