def output(stream):
    """Write the contents of the given stream to stdout."""
    while True:
        content = stream.read(1024)
        if len(content) == 0: break
        sys.stdout.write(content)