Turns out opening the file twice is better performing.

First we only read the first 512 bytes and then only opening
the full files that will be processed.