From a previous post (see below): How could I modify this to copy out multiple sections of a text file each beginning and ending with "start and "end" strings? This code only will find one instance of "start" and "end" if not mistaken (per a previous post).
with open('path/to/input') as infile, open('path/to/output', 'w') as outfile:
copy = False
for line in infile:
if line.strip() == "Start":
outfile.write(line) # add this
copy = True
elif line.strip() == "End":
outfile.write(line) # add this
copy = False
elif copy:
outfile.write(line)