return bytes.decode('utf8')

def main():
    fn = sys.argv[1]
with open(fn + '.indx', 'rb') as f:
    findex = array.array('l')
findex.fromfile(f, 1)
findex.fromfile(f, findex[0])
findex[0] = -1
with open(fn, 'rb') as f:
    for n in sys.argv[2:]:
        print((n, repr(readline(int(n), f, findex))))
main()
Перемещение в произвольную позицию в файле в Python