I am trying to open a text file and copy lines from "FIRST TEXT" until "LAST TEXT HERE" and write it to another text file. I am not sure how to go about completed this.
with open('SumBillRpt2019-2-27 Cyl 20.txt') as original_file,
open('test.txt', 'w') as new_file:
for line in original_file:
if line.strip() == 'FIRST TEXT HERE' in line.strip():
new_file.write(original_file.read())
if line.strip() == 'LAST TEXT HERE':
new_file.write(original_file.read())