Properly check return values of fread()