This is not a nice way of doing it, but would ensure that every correct catalog number is caught. The trick is to run a loop going through every line (yeah ... all 10,100) and comparing the number to the range wanted. The loop wouldn't exit at the first out of range catalog number. It's not very neat but it gets the job done.
Alternatively if the catalog is in order (ie: the file is ordered by ascending catalog numbers), you could exit the loop when the catalog number is equal to $last+1. Thereby catching all the references to $last.