replace printed statements in python 2.7,sys.stdout.flush()