Factor out outputter.
Add outputter spec, fix newline handling.
Remove example code, add Unix interface.