import json
# define list with values
basicList = [1, 2, 3, ..., 10000000]
# open output file for writing
with open('listfile.txt', 'w') as filehandle:
json.dump(basicList, filehandle)
I created a very long list and wrote it to a file. How can I now add a single element to the file without reading and rewriting the whole file?