substr for streams