Modifying txt files in Grasshopper

I’m trying to modify an input file (txt) to include additional data in a specific line without removing the data already existing in it, only pushing it down. How can I add this information through a python component?
Thanks for the help!

Hi there,
Stack overflow is probably the best source for general Python questions like this.

It is possible to append text to the end of a file, but inserting data into the middle of a file is much harder, if it can be done at all. I recommend just reading the entire file into a string, modifying that string in memory and then write out the modified string to the same location, thus completely overwriting the original file.