before locking stream