Lext01, the identifier $readn is what you're looking for to return the line number you read.
alias example {
var %rline = $readn
if ($read(file.txt,w,$+(*,$$1-,*))) {
write -dl $+ %rline file.txt
}
}
This is just a rough example...
As 5618 said, you may have missed the text file name.