So I want to read through a file checking each line to see if it contains part of the string I am looking for. Once I find the correct line I then want to re-write that line in the file.
Here is what I have so far:
f = open("playlist.py", "r+")
for line in f:
if old in line:
f.write(" " + str(item) + ":" + " " +
"\"" + new_text + "\"")
f.close()
break
f.close()
This code is finding the correct line but writing to the end of the file. I kinda figured the read and write iters would be shared but I guess not :(