title: How to extract a single line in a TXT file
body: <p><strong>I already have a code that extracts the subject line of a letter from a txt file:</strong></p>
  <pre><code>import os
  ans = []
  
  for filename in os.listdir(os.getcwd()):
     with open(os.path.join(os.getcwd(), filename), 'r') as rf:
      for line in rf:
          line = line.strip()
          if line.startswith(&quot;subject&quot;):
              ans.append(line)
          elif line.startswith(&quot;Subject&quot;):
             ans.append(line)
      
  with open('extracted_data.txt', 'w') as wf:
      for line in ans:
          wf.write(line)
  </code></pre>
  <p><strong>However, it gets formatted like this:</strong></p>
  <pre><code>subject: Block 8 of EricssonSubject: Block 9 of Ericssonsubject: Block 10 of Ericssonsubject: Block 11 of Ericsson
  </code></pre>
  <p><strong>When I want it to look like this:</strong></p>
  <pre><code>subject: Block 8 of Ericsson
  Subject: Block 9 of Ericsson
  subject: Block 10 of Ericsson
  subject: Block 11 of Ericsson
  </code></pre>
  <p>How do I get it to format in the above desired way?</p>