title: Out-File writes an empty file
body: <p>I am on a system that is on PowerShell v2.</p>
  
  <p>I have a script that deletes old backups files. I would like to save the results of the script, as I see it on the on screen to be written to a file so that I can review what all files were deleted.</p>
  
  <p>I read that <code>Write-Host</code> output that I see on the screen cannot be redirected to a file so I tried using the <code>Write-Output</code> as well, but can get the results to be written to the file. The file get created, but it's empty.</p>
  
  <p>What am I doing incorrectly here?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>$Stamp1 = Get-Date -Format "MMddyyyy_hhmmss"
  $File= "E:\SSBackups\PS_Delete_Script_logs\Delete_Backup_Results_$Stamp1.txt"
  $ReadFile = Get-Content C:\Users\MSA050415\Desktop\List.txt
  foreach ($Folder in $ReadFile) {
      #Write-Host "Folder currently being worked on: $Folder" -ForegroundColor Magenta
      Write-Output "Folder currently being worked on: $Folder"
      $Path ="E:\SSBackups\Database_Backups\$Folder"
      #Write-Host "The Path is set to $Path" -ForegroundColor Green
      Write-Output "The Path is set to $Path"
      Get-ChildItem $Path |
          Where-Object {$_.LastWriteTime -lt "4/17/2018 12:15:00 AM"} |
          Remove-Item -Verbose |
          Out-File $File
  }
  </code></pre>