Do you really need to do all this seeking and reading? Can't you just slurp the first `search_range` bytes and then scan those? And would it be simpler to convert `expected_value` into a byte sequence and just use `bytes.index(expected_value)`?