FYI, keys would be very inappropriate in this case, because it would read the file twice ... build a complete list of the record keys in RAM (virtual memory) ... then retrieve the records by those keys. Most of the time you would run out of RAM. But even if you didn’t, you’d be doing a rather massively too-much amount of unnecessary work.
each, on the other hand, simply walks through the file. There is no memory-footprint to speak of. Furthermore, it always does so in ascending order by key. Very often, that is exactly what you want. (What bearing if any this may have on this issue, I don’t know.)