title: In Powershell how can I use lines in a CSV to search a text file and return multiple lines to another CSV?
body: <p>Example of what I am trying to do.</p>
  <p>I have CSV_A.CSV that contains a list of keywords (each on a new line) like: apple, orange, pear. Note these keywords only occur in the TEXT_FILE exactly 1 time.</p>
  <p>I have a text file TEXT_FILE.TXT that has 1000s of lines. I need a script that will search TEXT_FILE for apple, then orange, then pear and return its line as well as the next 5 lines.</p>
  <p>So the ending result would be a file that contains 15 lines, 5 for each of the 3 key words.</p>
  <p>Currently I have tried the following code and it gives me the first line for each keyword, but nothing more.</p>
  <pre><code># path
  $path = 'C:\Users\Documents\4_Testing\TEXT_FILE.TXT'
  
  
  Import-Csv .\CSV_A.csv | ForEach-Object {
      Get-ChildItem -Path $path | Select-String -Pattern &quot;$($_.KeywordColumn)\(&quot; -Context 0, 5 |
      Select-Object Line |
      add-content -path 'C:\Users\Documents\4_Testing\Output.csv'
  }
  </code></pre>