Finish off the file parsing code and split into two smaller, easier-to-test methods.