Help with performance (file io)

What version of Ruby is that? Not all of them will use UTF-8 by default.

You could also load the whole file into memory first, rather than stream. If I’m not mistaken that’s what the Ruby version does.