open for appending [textoutput open('output txt' ' if you do not want to overwrite the content of the fileyou can also open file for appending with mode 'ain all other regards appending will be the same as writing