Convert xmlhttp textstream to csv

I’m rewriting an old vbscript to powershell.
It uses xmlhttp to get data. It then does some fancy footwork using to convert xmlhttp.responseBody to text and then eventually to csv.
If I look at $XmlHttp.responsetext it appears to be a text stream in the format of a csv file. Does anyone have any ideas how I can convert this text stream to a csv file please?
David Z

Found it!

$XmlHttp.responsetext | out-file D:\scripts\SourceFiles\r.txt
$csv = import-csv D:\scripts\SourceFiles\r.txt

Too simple!

Nope the above didn’t work exactly
This is what I needed to do:

$stream = new-object -com ADODB.Stream
$stream.type = 1 # Binary
$stream.savetofile($rawfile,2) # 2 = overwrite existing or create new
$stream = $nul
$hpsd = import-csv $rawfile