reading specific lines from a file
<p>What's the best way of reading only the specific lines (based on matching text) from a file? This is what I'm doing now:</p>

<pre><code>match_txt = "lhcb"
for inFile in os.listdir('.'):
    readFile = open(inFile, 'r')
    lines = readFile.readlines()
    readFile.close()

    for line in lines:
        if line.find(match_txt)==0:
           #&lt; do stuff here &gt;
</code></pre>

<p>i.e. I'm reading the lines, only with "lhcb" in it, from all the files in the present directory one by one. Is it the best way of doing that? Can it be done without loading the whole file in the memory in the first place?</p>
