well, for starters you may try /help if-the-else because your obviously unknowledgable of the proper syntax. And just to give you an idea, the conditions your trying require a second parameter such as "if ($nick isreg)" SHOULD be "if ($nick isreg $chan)"
As for the line number, why should it return a line number. You know what you just edited, look there. Do you always make 100 line edits inbetween trials?