Use `Stream.with_index` instead of custom `reduce_with_index`