Are you SURE it works?
$readn when used at the top like that will show the last line read BEFORE the alias was called. It won't give you the line number that you JUST read. Try it using different searches that return different line numbers and you'll see what we mean.
Anyhow, to the OP, /write should have -dl $+ $readn (or a variable or number) before the filename and the text being written. Putting anything between /write and -dl isn't going to work.