cw.c: filter more efficiently

Process the input a line at a time, using memmem to find line endings.

Output using dprintf, avoiding stderr.