fix CLI bug on EOF
(cherry picked from commit 6c970a6)