open for writing [textoutput open('output txt' 'this will truncate an existing file opening file for writing is the same as opening it for reading except that the mode is 'wfor writing if the file already exists then this overwrites it the file gets truncated to zero bytes long because you haven' written to it yet