Fixed the output issue (thanks, @davehull for finding my bug). Now, however, it's pushing out too many lines. :/