@staticmethod
def _do_stream(data, stream):
    """Helper function for _mergeStdout"""
    for line in data.splitlines(True):
        line = line.replace('\\n', '\n# ')
        if line.startswith('#'):
            stream.write(line)
        else:
            stream.write('# ' + line)
    if not line.endswith('\n'):
        stream.write('\n')
