Added function consumeStream.