I'm having a problem with how can I write a string in every new line in a text file. Please see attached image:
Above image is the original text file. Now I want to add some text in every newline. Please see attached image:
Now I added the word "END". How can I do it in python? I tried to use the normal file reading then adding this stuff:
if 'PING' in line:
new_file.write("END")
elif 'ST' in line:
new_file.write("END")
etc. .
But I think this way isn't flexible. Do you guys have any ideas on how can I do it? Thank you very much!


"\n\n"with"\nEND\n".