fout = open('names.txt', 'w') output = [] name = input("Please enter your name (or 0 to stop): ") while name != "0": birthdate = input("Birthdate: ") color = input("Favorite color: ") output.append('\t'.join((name, birthdate, color))) name = input("Please enter your name (or 0 to stop): ") fout.writelines(output) fout.close()