Properly handle outputting newline (and other control characters.)
Add some rudimentary automated tests.