title: search for a string from property file and print the lines in Python
body: <p>I am trying to print the line of a file if the string is matched from the list.</p>
  <p><strong>Step #1</strong> -
  I am getting list of Accounts/users from a db as txt file and the content will be looking like this</p>
  <p>list_from_db.txt</p>
  <pre><code>userA
  userB
  userC
  </code></pre>
  <p>I am converting this .txt file to a list first with the below code -</p>
  <pre><code>lineList = [line.rstrip('\n') for line in open(&quot;list_from_db.txt&quot;)]
  print(lineList)
  </code></pre>
  <p><em>output-</em></p>
  <pre><code>['userA','userB','userC']
  </code></pre>
  <p><strong>Step #2</strong> -</p>
  <p>Now i am searching this list of strings with a property file and the content will looks like this</p>
  <p><em>user.properties</em></p>
  <pre><code>GIT_url = https://giturl:9000
  url_usercontent= redirection
  value.userB.duplicate=yes
  checkif.userC.exist=on
  </code></pre>
  <p>My code to check if the content from my list is present in this file  -</p>
  <pre><code>   with open(&quot;user.properties&quot;) as f:
            file_content = f.read()
      #lineList is a list which i am taking from Step #1
      for x in lineList:
          if x in file_content:
              print(x)
  </code></pre>
  <p><em>my output-</em></p>
  <pre><code>userB
  userC
  </code></pre>
  <p>I am able to print the matching string but i need the entire line from my property file.</p>
  <p><em>Expected output</em> -</p>
  <pre><code>value.userB.duplicate=yes
  checkif.userC.exist=on
  </code></pre>
  <p><strong>Edit #1(Edge case)-</strong>
  If my list contains a string &quot;user&quot; then it should only consider that value instead of relative value.</p>
  <p>For eg : if i have my list like this -</p>
  <pre><code>['user','userA','userB','userC']
  </code></pre>
  <p>It should not print me the all output relevant to &quot;user&quot; from the list-</p>
  <p>it should still give me the expected output as mentioned above -</p>
  <pre><code>value.userB.duplicate=yes
  checkif.userC.exist=on
  </code></pre>
  <p>it should not print the output like this -</p>
  <pre><code>url_usercontent= redirection
  value.userB.duplicate=yes
  checkif.userC.exist=on
  </code></pre>
  <p>Kindly help .</p>