First thing I would suggest, rather than using a script to identify all of your registered nicks, especially if they all use the same password (as it appears they do), check the nickserv options on the network and see if it supports the group function.

You can do this quickly and easily using
Code:
/msg nickserv help group

You'll either get the help information, or you'll get a message indicating that the group option isn't available.

If it is available, I suggest you pick one main nick, then group the rest to that nick. Then you only have to identify for one nick, and the rest will be identified for automatically.