Fixed a lock case by checking stdin.flush()