guests = []
while True:
value = input("Please input a guest name, or 'q' to quit: ")
if value == "q":
break
if len(value) > 0:
guests.append(value)
if len(guests) > 0:
with open("guests.txt", "w") as file_obj:
file_obj.write("\n".join(guests))
print("List saved to guests.txt.")