There is no $nick in RAW events. Or more accurately, $nick returns the name of the server you are currently connected to (which is the server that sent you the RAW response.)
Also, if that is exactly how your script looks, you will have issues because your RAW event ends on the first line. All the other lines are not within an event or alias at all.
-genius_at_work