title: Set-Content appends a newline (line break, CRLF) at the end of my file
body: <p>My original config file (web1.config) has no extra line and when viewed in notepad (showing all characters) looks as:</p>
  
  <p><a href="https://i.stack.imgur.com/VqAjW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VqAjW.png" alt="enter image description here"></a></p>
  
  <pre><code> &lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.6" /&gt;
      &lt;httpRuntime targetFramework="4.6" /&gt;
    &lt;/system.web&gt;
    &lt;appSettings&gt;
      &lt;add key="myConnectionString" value="server=localhost;database=myDb;uid=myUser;password=myPass;" /&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Now, I need to apply the script to change my database name to something else which looks like:</p>
  
  <pre><code> Move-Item "web1.config" "webtemp.config"
  Get-Content "webtemp.config" | ForEach-Object {$_ -replace "database=myDb;", "database=newDb;"} |Set-Content "web1.config" -Force
  Remove-Item "webtemp.config"
  Write-Output('Settings Changed')
  </code></pre>
  
  <p>So, the new file (web1.config) generated looks as:</p>
  
  <p><a href="https://i.stack.imgur.com/eu9BR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eu9BR.png" alt="enter image description here"></a></p>
  
  <p>Notice the extra line added at the end of the file (which is completely not needed)
  I tried all other options such as:
  - using out-file api
  - using .net IO method System.IO.StreamWriter
  - using -nonewline flag (it converts all 10 lines into single line)
  - using different encoding options
  - tried replacing \r\n to \r (don't work as again set-content generates the crlf always)</p>
  
  <p>I'm using PowerShell v5.1.</p>