<div dir="ltr"><div><div><div>Hi all, <br><br></div>I am trying to write the below code to be able to read from a text file and fine lines that start with <br></div>TRAN  and then write this line and the next 2 following lines to another file called Output.txt.<br>

<br></div>my code is as below:<br><br><br><div>with open('p.txt') as f1:<br>  with open('Output.txt', 'a') as f2:<br>    for line in f1:<br>      if line.startswith('TRAN'):<br>    print("true")<br>

        f2.write(line)<br>        f2.write(f1.next())<br>        f2.write(f1.next())<br><br></div><div>but
 when i type python he.py in folder where the p.txt and Output.txt are 
located, nothing happens and no data is written to the output file.<br>
<br></div><div>Could somebody please tell me where is my error?<br><br></div><div>Thanks in advance<br></div>Heidi</div>