Check the return value of fread

This silences warnings on linux/gcc.
Merge pull request #1511 from mstorsjo/check-fread-return-value

Check the return value of fread