added explicit ending of the stream