This program works, but it has some "quirks" in its behavior: it didn't print the beginning of the test file, and cut off after line 17.