couldn't you just use "sort" to sort the file on disk and then offset into the file to find the answer? i would expect sort to work fine for files larger than memory (and if it doesn't i bet there is some tool that does - merge sort with tapes is not so old...)
[edit: you'd need to add, then strip, carriage returns between numbers, i guess]
[edit: you'd need to add, then strip, carriage returns between numbers, i guess]