I know that I can use:
gc c:\\FileWithEmptyLines.txt | where {$_ -ne \"\"} > c:\\FileWithNoEmptyLines.txt
to remove empty lines. But How
(Get-Content c:\FileWithEmptyLines.txt) | Foreach { $_ -Replace "Old content", " New content" } | Set-Content c:\FileWithEmptyLines.txt;