refs.c: fix fread error handling