I was trying to modify in order to get secuencial access, not random.
Sorry, but that makes no sense at all. You have to read the entire file sequentially once in order to build an index.
If you want to process the file sequentially, just read it sequentially. There is nothing to be gained by using an index unless you need random access.