title: Why does [IO.File]::WriteAllText concatenate the Get-Content -tail ## output, and Set-Content does not?
body: <p>If this is a duplicate question for this specific issue, forgive me and please kindly point me in the right direction - I have not seen this in Stack Overflow so far.</p>
  <p>I'm using <code>PowerShell</code> to run a set of commands as follows to find 'NUL' char's in a file.  (<code>-replace</code> works just fine - this is not my problem)</p>
  <pre><code>$findString = '\x00'
  $replString = 'DERPS'
  $foo = [IO.File]::ReadAllText(&quot;C:\SomeFile.txt&quot;)
  $bar = $foo -replace $findString, $replString
  [IO.File]::WriteAllText(&quot;C:\SomeFile_2.txt&quot;, $bar)
  $Lines = Get-Content &quot;C:\SomeFile_2.txt&quot; -tail 10
  #I have also used the following with the same effect:
  #$Lines = Get-Content &quot;C:\SomeFile_2.txt&quot; |Select-Object -last 10
  [IO.File]::WriteAllText(&quot;C:\FOOBARRED.txt&quot;, $Lines)
  Set-Content &quot;C:\NOT_FOOBARRED.txt&quot; $Lines
  
  </code></pre>
  <p>What I'm experiencing is with <code>[IO.File]</code> it concatenates the last 10 lines into one string:</p>
  <pre><code>Line 1 of 10 Line 2 of 10 Line 3 of 10 Line 4 of 10 Line 5 of 10 Line 6 of 10 Line 7 of 10 Line 8 of 10 Line 9 of 10 DERPSDERPSDERPSDERPSDERPS
  </code></pre>
  <p>With <code>Set-Content</code> my output looks correct:</p>
  <pre><code>Line 1 of 10
  Line 2 of 10
  Line 3 of 10
  Line 4 of 10
  Line 5 of 10 
  Line 6 of 10 
  Line 7 of 10
  Line 8 of 10
  Line 9 of 10
  DERPSDERPSDERPSDERPSDERPS
  </code></pre>
  <p>Can anyone explain what the difference is?  Is it correct to assume the &quot;WriteAllText&quot; Command works when it's a raw format, but if it's processed in anyway it will accept the data as one large blob?</p>