Will be trouble if try to generate new file in each loop.
So have the making of file object outside of the loop,then write to file in the loop.
So have the making of file object outside of the loop,then write to file in the loop.
file_name = "temp.txt" with open(file_name, "a") as file: while True: name = input("Your name, again:") if name == "": break else: file.write(f'{name}\n')