I've looked around for quite a bit on this, but I haven't seen examples on how to do this. I apologize if this has been answered before, I was unable to find it.
I know the basic idea behind the concept: Make a temp text file, copy the text before the line you want to edit to the temp text file, make the edit to the line in the new file, copy the rest to it, overwrite the old file, and delete the temporary file. However, I haven't seen any examples on how to do this. If this is incredibly simple, I am really sorry, I'm kinda learning as I go here.