Only emit trailing newline if stdout is a TTY

This fixes round-tripping and testing with pipelines like this:

echo -n 'foo' | node parse | node parse --html2wt

At the same time, it still prints the trailing newline when used from a shell.

Change-Id: I6f7f9703769b3326a2cb20e6afbcaf8363e0b912
Merge "Only emit trailing newline if stdout is a TTY"