Fixed bug of calling primitive stream twice.

This happens when both simpleStream's and primitiveStream's
prepareWrite() are called and waiting, and closeWrite is called.