fix bug/error for windows
fix bug, waiting while tmp file for printf isn't empty