First open the file that you want to append in append(a) mode and then write into it
Ex:
with open("example.txt", "rb") as myfile:
myfile.read()
'This is the text that already exists'
with open("example.txt", "a") as myfile:
myfile.write("\nThis text will be append to the file");
with open("example.txt", "rb") as myfile:
myfile.read()
'This is the text that already exists
This text will be append to the file'