Check isatty before attempting readline

This fixes the problem where running commands from the CLI hangs until you press return.