I want to replace a line in a text file using Python. Basically I am looping over a file and when I find a relevant line that needs to be replaced, I want to replace it at the same position in the file.
Can this be done in Python without creating a completely new file?