Allowed a stream object to be passed in to the constructor to make it more general and added an example