title: Overwriting output file?
body: <p>I am extracting some errors from a log file into a separate file.</p>
  
  <p>The errors that I am searching for are defined in a little block:</p>
  
  <pre><code># Define all the error types that we need to search on
  $error_6  = "Missing coded entry in table for provider sector category record"
  $error_7  = "not a well-formed email address"
  $error_8  = "Org Id must not contain invalid characters"
  $error_9  = "Missing sub type code for provider type category record"
  $error_10 = "Provider sub type"
  </code></pre>
  
  <p>I then read in the source log file and strip out the matching lines.</p>
  
  <p>Weirdly, if I dump them into separate files I get the correct number of lines in each file, but if I use the same file I only get one line. I thought that it would append to the file.</p>
  
  <p>This doesn't work (only one line of output):</p>
  
  <pre><code>(Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_6 } |   Set-Content $path\known_errors.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_7 } | Set-Content $path\known_errors.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_8 } | Set-Content $path\known_errors.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_9 } | Set-Content $path\known_errors.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_10 } | Set-Content $path\known_errors.log
  </code></pre>
  
  <p>Works (16 lines of output in total):</p>
  
  <pre><code>(Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_6 } | Set-Content $path\known_errors_6.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_7 } | Set-Content $path\known_errors_7.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_8 } | Set-Content $path\known_errors_8.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_9 } | Set-Content $path\known_errors_9.log
  (Get-Content $path\temp_report.log) | Where-Object { $_ -match $error_10 } | Set-Content $path\known_errors_10.log
  </code></pre>