fix boundary condition in buffered-stream