Split a text file using the header
<p>I have an input text file which I am reading and storing everything in a list. After that I'm splitting the list according to the specific text occurence in the list. </p>

<p>Here is the function.</p>

<pre><code>import re
def readFile1(file1):
    f = file1.read().split('\n')
    #print f
    ctrlList1 = []
    mfcList1 = []

    for str in f:
        if re.search("MegaMon&gt; mfc",str):
            print "splitting\n"
            break
        else:
            ctrlList1.append(str)

    print ctrlList1, "\n\n\n"
</code></pre>

<p>This works fine and saves <code>ctrlList1</code> until the text <code>megamon&gt; mfc</code> appears in the main list. But I want to save the lines after <code>MegaMon&gt; mfc</code> in <code>mfcList1</code>. I am not able to do that. </p>

<p>I tried:</p>

<pre><code>if not re.search("MegaMon&gt; mfc", str):
   print "splitting\n"
   continue
else:
    mfcList1.append(str)
</code></pre>

<p>but this doesn't seem to be working. I need to save the text file in two different lists. Any help would be appreciated.</p>
