def pop_stream(f):
 f.flush()
 f.seek(0)
 output = f.read()
 f.seek(0)
 f.truncate()
 return output

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 .