the problem is that: I have a text file with some lines of text in it. I have to search for a particular line in the file and then copy the lines after the searched line into another text file. This search string comes only once in the text file. I am able to search the line, but can't figure out how to copy the remaining lines into another file.
My code is as shown below:
f = open('testread.txt') f1 = open('testread1.txt', 'a') for line in f.readlines(): if 'this is the line i want to search' in line: # here i want to copy all the lines after the searched line in to another file using f1.write() f1.close() f.close()
Thanks for the help!