write lock/release and check output into stdout