Python For loop repeats second loop : <p>I have 2 files (a.txt and shell.txt)</p>

<p>in a.txt there are 59 lines and I've extracted their domains with the regex</p>

<p>in shell.txt there are 5881 lines.</p>

<p>The domains from a.txt exists in shell.txt and I want to extract the entire line of shell.txt if the domain of a.txt exists in shell.txt</p>

<p>Unfortunately my loops are not working right so I would like to get some help from you guys.</p>

<p>Thanks.</p>

<pre><code>import re

s1 = open('a.txt', 'r').read().splitlines()
s2 = open('shell.txt', 'r').read().splitlines()


for x in s1:

    c1 = re.findall("\/\/(.*)\/",x.split("|")[0])[0]

    for x2 in s2:

        c2 = re.findall("\/\/(.*)\/",x2.split("|")[2])

        if c1 == c2:

            print x2
</code></pre>
