I have a code to modify a file. This code make changes on my file and save it to a new file. But, I want to have changes(modifications) on my original file not a new one. I made attempts to change the code but it didn't work. How can I modify my code to save modification on my original file? My code is attached here.
with open('BTMA1.gro') as text_file, open('BTMA2.gro', 'w') as revised_file:
reader = csv.reader(text_file, delimiter=' ')
writer = csv.writer(revised_file, delimiter=' ', quoting=0)
for idx, row in enumerate(reader, start=1):
if idx >= 3:
row = row[1:]