fix #225: fix EPIPE errors when piped through head command

This fixes issue #225 where piping output through something like `head` could cause `EPIPE` errors.

It simply catches the EPIPE error and exits.
Any other `stdout` errors will be rethrown.