Short version, using your code:
$s = ""
cat $f | % {
if ($_ -match "^-") { $s += $_ } else { $s; $s = $_; }
} -end { $s } | out-file x.txt
longer version:
function glue {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true)]
$line
)
begin { $output = "" }
process { if ($line -match "^-") { $output += $line } else { $output; $output = $line; }
end { $output }
}
cat $f | glue | out-file x.txt