is there we can use the regex to parse the entire file and determine the matches were found , rather then reading each line by line?
<p>Instead on reading each and every line cant we  just search for the string in the file and  replace it... i am trying but unable to get any idea about doing that</p>

<pre><code> file = open(C:\\path.txt,"r+")
 lines = file.readlines()
    replaceDone=0
    file.seek(0)
    newString="set:: windows32\n"
    for l in lines: 
         if (re.search("(address_num)",l,re.I) replaceDone==0:
            try:
                file.write(l.replace(l,newString))
                replaceDone=1
            except IOError:
                 file.close()
</code></pre>
