Handle errors when writing to STDOUT.