Your regex example will output all the channels from the text file as
/join #chan1,#chan2,#chan3, with an extra comma at the end.