I think in the ON CONNECT event, you could do like this:
var %x = 1,%chans
while (%x <= $lines(AutojoinChannels.txt)) {
%chans = $addtok(%chans,$read(AutojoinChannels.txt,%x),44)
inc %x
}
if (%chans) { join %chans }
So, in this way you're just sending ONE command to join all the channels instead of sending one command per each channel.
Another suggestion: some networks/services are don't support /msg NickServ. Like DALnet; you must type /NickServ or /msg NickServ@services.dal.net... So, it's better to use /NickServ itself.