Fixes off-by-one error when finding missing endstream

Fixes #4387. Also removed unused variable `ii`.

Short explanation: we start with `i=0` and `j=0`. Assume we find the `e` of `endstream` immediately. Then `j` becomes 1, but `i` is still 0. `i` will be `1` in the next iteration, but when the `n` from `endstream` is then found `j` becomes 2, et cetera. In the end we will make `j` equal `9` and then stop, but `i` will then be `8`. Therefore this patch increases `i` by 1 to make them equal.