Simplify output-stream handling and avoid blocking the eventloop.