Refactored it to this, but the problem seems to be the consumption, or the lack-there-of the newline character