That's most probably because you have more than 1 WWN, and hence the $out variable will be an array.
Try changing this
$out = get-vmhost $esxihost | get-vmhosthba | get-scsilun | get-scsilunpath | Select -ExpandProperty SanID -unique -ErrorAction "SilentlyContinue"
into this
$out = get-vmhost $esxihost | get-vmhosthba | get-scsilun | get-scsilunpath | Select -ExpandProperty SanID -unique -ErrorAction "SilentlyContinue"
$out = [string]::Join(',',$out)
That way out will be a [string] and not an array.