Open oldoc63 opened 1 year ago
In the code above we open a file object in the temporary variable gen_file. This variable points to the file generated_file.txt and, since it's open in append-mode, adds the line ... and it still is as a new line to the file. If you were to open the file after running the script it would look changed.
There is a way to just add a line to a file without completely deleting it. Instead of opening the file using the argument 'w' for write-mode, we open it with 'a' for append-mode.