in reply to Reading records of various lengths

I think it would be a good idea to verify the file sizes before doing SHA digests. Truncated file, garbage at the end - either could be the cause of the symptoms you're seeing.