Check isatty before calling readline

This fixes the problem where commands hang on the CLI until you enter a newline.