I didn't post this in the games development section because the problem and it's solution are not hugely related to the game itself, more it's system.
Im glad you did. Most people think if their program in in tkinter then it must be a problem with that, but it really is a general python problem nothing related to it.
I worked out a system were the game loads a txt. and reads it to find out were the user was when they left off. (Putting it fairly simply, I have a save/load feature)
Anyways, the txt. contains just a single line, containing a number. I have got the load section working, but I still need to get the save working. How can I replace the first line on the txt. file? Or maybe just replace the whole thing, as it is just one line.
Normally what ends up happening is you eventually need to save more and more data. And you can either do each peice of data as a separate file or recode. Its better to recode and adjust for the addition than to just keep using the text method. So as you might need only one number to save now, later you might need 2 numbers, a float, a string, a dictionary, or a list, etc.
So long story short use json, shelve, or pickle, or some other similar method. So then you have a dictionary to load/save, and can add/delete to it, and not have to modify code to accomodate the change.
But to finally answer your question. With you only saving one number on line. I would just open the file in 'w' mode and redo the entire thing.
I am guessing you were asking about the line numbers because you see in the future that each line is a different piece of data? Yeah tried that also, its possible, not too hard, but the other methods make it a breeze. So in case this was your idea, just giving you a heads up
I am fairly experienced with python. Been using it for a few months as a computer science student.
I would not consider a few months fairly experienced. I have been doing python almost 2 years and i do not considered myself to be anywhere near that title yet.
A fairly experienced python programmer would have multiple methods of saving to and from a file. With the experience of doing so already. They would not be asking how to save/load data to and from a text file. They also would not really be programming a text based game (mostly not, not really set in stone though) . They would have already done so and most likely already programmed one or even two text based games by now. They would be more apt to be programming a 2d game or 3d game using a 3rd party library, for example.
I also have a fissy when people graduate college and consider themselves an expert just because they have a piece of paper. When in actuality they are raw in the field, very raw. Ok i am done with my rant. I just really dont like when people say they are someone who they are really not.