making writing to stdin synchronous