title: Remove spaces and blank lines from txt files
body: <p>I have a script which is not working:</p>
  
  <pre><code>$files = Get-ChildItem "C:\test\"
  for ($i=0; $i -lt $files.Count; $i++) {
    $outfile = $files[$i].FullName + "out" 
    Get-Content $files[$i].FullName | ? {$_.Trim() -ne "" } | Set-Content $files[$i].FullName
  }
  </code></pre>
  
  <p>Error is:</p>
  
  <pre>Set-Content : The process cannot access the file 'C:\test\ADMINISTRATOR.txt'
  because it is being use
  At D:\skriptablank.ps1:4 char:63
  +     Get-Content $files[$i].FullName | ? {$_.Trim() -ne "" } | Set-Content $files ...
  +                                                               ~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [Set-Content], IOException
      + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.SetContentCommand</pre>
  
  <p>What do you think, where I am doing it wrong?</p>