Call file.readlines() with sizehint in a loop to avoid reading in massive files all at once