How to write to a file without overwriting current contents? [duplicate]

Instead of "w" use "a" (append) mode with open function:

with open("games.txt", "a") as text_file:

Leave a Comment