def pop_stream(f):
    f.flush()
    f.seek(0)
    output = f.read()
    f.seek(0)
    f.truncate()
    return output
read everything out of file from the top and clear it out
dataset/ETHPy150Open openstack/swift/test/unit/common/test_manager.py/pop_stream