When I\'m saving content of the String[] array with System.IO.File.WriteAllLines, at the end of a file is always left a blank line. For example:
System.IO.Fi
The easiest way for me to do it was usning AppendAllText for last line:
if ($i -ne $lines.Count - 1){ $newLines += $lines[$i] } else { $lastLine = $lines[$i] } [IO.File]::WriteAllLines($file.FullName, $newLines); [IO.File]::AppendAllText($file.FullName, $lastLine);