returning string index and destroying stream when found