Code:
if ($read(reglist.txt,nw,$3)) write -dl $+ $readn reglist.txt 


It's amazing how much info you can obtain from reading the help files.
Quote:

/write [-cidna l# s# w# r#] <filename> [text]

Writes lines to a text file. For example:



/write store.txt This line will be appended to the end of file store.txt



The -c switch clears the file completely before writing to it, so it allows you to start with a clean slate.



/write -c c:\info.txt This file will be erased and have this line written to it



The -l# switch specifies the line number where the text is to be written.



/write -l5 c:\info.txt This line will overwrite the 5th line in the file



The -i switch indicates that the text should be inserted at the specified line instead of overwriting it. If you do not specify any text then a blank line is inserted. If you do not specify a line number then a blank line is added to the end of the file.



/write -il5 c:\info.txt This line will be inserted at the 5th line in the file



The -d switch deletes a line in the file. If you do not specify a line number then the last line in the file is deleted.



/write -dl5 c:\info.txt



The above command will delete the 5th line in the file.



The -s# switch scans a file for the line beginning with the specified text and performs the operation on that line.



/write -dstest c:\info.txt



This will scan file info.txt for a line beginning with the word "test" and if found, deletes it.



If you do not specify any switches then the text is just added to the end of the file.



The -w# switch scans a file for the line containing the specified wildcard text and performs the operation on that line. The -r# switch implies a regex match.



Note: With both -s# and -w# you can enclose the scan text in quotes if it contains spaces.



The -a switch indicates that mIRC should append the line of text you specified to the existing text of the specified line.



The -n switch prevents it from adding a $crlf to the end of the text.



Note: You cannot use this command to write to an INI file. If you do so, you will most likely corrupt the INI file.



Quote:

$readn

Returns the line number that was matched in a previous call to $read(). If no match was found, $readn is set to zero.



Last edited by Nillen; 07/04/14 06:14 PM. Reason: Forgot the $readn quote