By reading the file in two passes.
The first pass just counts the lines in the file.
The second pass starts by preallocating the correct number of lines, and
then reads the file.
The whole time saving comes from not having to dynamically resize the
lines slice while reading the file.