added check on return value from fread to make it compile without warning