Check the return value from fread

This fixes build failures on linux due to building with -Werror,
since fread is marked with the warn_unused_result attribute
in certain glibc versions.