Use sys.stdout.write instead of print