Add lines to existing file using Python July 8, 2023 by Tarik Open the file for ‘append’ rather than ‘write’. with open('file.txt', 'a') as file: file.write('input')