Search Specific Keyword From a File and add description associated to it to different file with Python
<p>Below text file shows the Description of Channel Name &amp; the Channel Event</p>

<p><strong><em>desc.txt file:</em></strong></p>

<pre><code>Channel Name: CBS
Event Name: FIFA World Cup 2018 Qualifying

Channel Name: BEINSPORTS
Event Name: NFL 
</code></pre>

<p>Below Python code only looks for the First "Event Name" and associated description. </p>

<pre><code>flist = open('/tmp/desc.txt').readlines()
    for line in flist:
        if line.startswith("Event Name:"):
            eventname = line[12:-1]                  
            file2 = open('/tmp/test_live.txt','w')
            file2.write(eventname + "\n")
</code></pre>

<p>What I want is the below description and what I am getting currently is 
"FIFA World Cup 2018 Qualifying" in the file. </p>

<p><strong><em>test_live.txt</em></strong></p>

<pre><code>FIFA World Cup 2018 Qualifying
NFL
</code></pre>

<p>Notice that you're opening the file in write (<code>'w'</code>) mode so the entire content of the file test_live.txt is wiped with every iteration. Use append (<code>'a'</code>) mode instead.</p>

python file python-3.x