Fixes off-by-one error when finding missing endstream