Fix bug in stream iteration