need cmdlet or ps script

$hddts=Get-ADComputer -Filter ‘name -like “hddt*”’|select -ExpandProperty name
foreach($hddt in $hddts){if(Test-Connection -ComputerName $hddt -Count 1 -Quiet){
$hddt|Out-File C:\Users\dt203976\Desktop\hddtpingable.txt}
else{$hddt|Out-File C:\Users\dt203976\Desktop\hddtnotpingable.txt}

above is my script to test the connection to AD computers , my requirement is to copy all the live machines to one txt file and not in live machines to another txt file .

but here, file name “hddtpingable.txt” is replacing existing data with current instead writing sequence , please help in correcting myscript by adding any cmdlet which fulfil my requirement

Look at the help for Out-File and see if the -Append parameter has any use to your requirement.