its easier to use a simple $regsubex to loop through your channels instead of using while and doesn't use any vars and takes much less code in general
alias chans return $regsubex($str(.,$chan(0)),/./g,$chan(\n) $chr(32))