Improvements to the command-line tool.

- Don't read the whole input to memory.
- Support reading from stdin and writing to stdout.