Write output to a given writer, not only stdout.