code: private String mainLoop(ConsoleReader reader, PrintWriter cout) throws IOException {
  		InputReader lr = new ConsoleInputReader(reader);
  		
  		String line;
  		while ((line = reader.readLine()) != null) {
  			if (line.isEmpty()) {
  				continue;
  			}
  			
  			String[] args = ShellCommandParser.split(line);
  			
  			Result pr;
  			try {
  				pr = ShellCommandParser.parse(args, EXCLUDED_COMMANDS);
  			} catch (OptionParserException e) {
  				//there is an option, only commands are allowed in the
  				//interactive shell
  				error(e.getMessage());
  				continue;
  			} catch (IntrospectionException e) {
  				//should never happen
  				throw new RuntimeException(e);
  			}
  			
  			Class<? extends Command> cmdClass = pr.getFirstCommand();
  			
  			if (cmdClass == ShellExitCommand.class ||
  					cmdClass == ShellQuitCommand.class) {
  				break;
  			} else if (cmdClass == null) {
  				error("unknown command `" + args[0] + "'");
  				continue;
  			}
  			
  			Command cmd;
  			try {
  				cmd = cmdClass.newInstance();
  			} catch (Exception e) {
  				//should never happen
  				throw new RuntimeException(e);
  			}
  			
  			boolean acceptsInputFile = false;
  			if (cmd instanceof ProviderCommand) {
  				cmd = new InputFileCommand((ProviderCommand)cmd);
  				acceptsInputFile = true;
  			}
  			
  			args = ArrayUtils.subarray(args, 1, args.length);
  			args = augmentCommand(args, pr.getLastCommand(), acceptsInputFile);
  			
  			try {
  				cmd.run(args, lr, cout);
  			} catch (OptionParserException e) {
  				error(e.getMessage());
  			}
  		}
  		
  		return line;
  	}
docs: Runs the shell's main loop
  @param reader the console reader used to read user input from
  the command line
  @param cout the output stream
  @return the last line read or null if the user pressed Ctrl+D and
  the input stream has ended
  @throws IOException if an I/O error occurs