Python: updated to use sys.stdout.write to remove extra trailing space