# File lib/pry/pry_instance.rb, line 329
  def retrieve_line(eval_string, target)
    @indent.reset if eval_string.empty?

    current_prompt = select_prompt(eval_string, target)
    indentation = Pry.config.auto_indent ? @indent.indent_level : ''

    val = readline("#{current_prompt}#{indentation}")

    # invoke handler if we receive EOF character (^D)
    if !val
      output.puts ""
      Pry.config.control_d_handler.call(eval_string, self)
      return
    end

    # Change the eval_string into the input encoding (Issue 284)
    # TODO: This wouldn't be necessary if the eval_string was constructed from
    # input strings only.
    if should_force_encoding?(eval_string, val)
      eval_string.force_encoding(val.encoding)
    end

    if Pry.config.auto_indent && !input.is_a?(StringIO)
      original_val = "#{indentation}#{val}"
      indented_val = @indent.indent(val)

      if original_val != indented_val && output.tty? && Pry::Helpers::BaseHelpers.use_ansi_codes? && Pry.config.correct_indent
        output.print @indent.correct_indentation(current_prompt + indented_val, original_val.length - indented_val.length)
        output.flush
      end
    else
      indented_val = val
    end

    begin
      if !process_command(val, eval_string, target)
        eval_string << "#{indented_val.rstrip}\n" unless val.empty?
      end
    ensure
      Pry.history << indented_val unless input.is_a?(StringIO)
    end
  end