You do not want to welcome the client that runs the code, and you have to make sure welcome.txt exists or you'll get an error:
on !*:join:#: {
if ($isfile(welcome.txt)) { msg # $read(welcome.txt) }
}
on *:text:!aw *:#: {
if ($nick(#,$nick,vr)) {
msg # sorry only mod status can add welcomes!
}
else {
write welcome.txt $2-
msg # $nick $+ , your greeting messege has been added.
}
}