You are right, chewing bytes is time consuming. But my code is to be applied on files that are larger than my system memory. Maybe reading larger chunks into memory would be faster. I'll test different solutions since that is the best way to get experience.