title: How to remove newlines from a text file with batch or PowerShell
body: <p>Essentially, I want to read from file.txt with contents</p>
  
  <pre>
  apple
  banana
  carrot
  </pre>
  
  <p>and write to newfile.txt so that it will have contents</p>
  
  <pre>
  apple banana carrot
  </pre>
  
  <p>I need to do this on a Windows computer on which I do not have install permissions.</p>
  
  <p>I tried </p>
  
  <pre><code>set row=
  for /f %%x in (file.txt) do set row=%row% %%x
  echo row &gt; newfile.txt
  </code></pre>
  
  <p>and I tried using PowerShell statements (I cannot run PowerShell scripts) instead of the CMD-style <code>for</code> loop.</p>
  
  <pre><code>powershell -Command "(Gc file.txt) | Foreach-Object -Process {set row=%row% _$} | Out-File newFile.txt"
  </code></pre>
  
  <p>but both produce an empty file. 
  Is there a way to do this?</p>