Fix infinite loop stdin issue on EOF