code: def _read(self, location):
          
          for io in self.editor.io_backends:
              if io.can_open_location(location):
                  # Found an I/O backend.
                  exists = io.exists(location)
                  self.isdir = io.isdir(location)
  
                  if exists in (True, NotImplemented):
                      # File could exist. Read it.
                      self.is_new = False
                      try:
                          text, self.encoding = io.read(location)
  
                          # Replace \r\n by \n.
                          text = text.replace('\r\n', '\n')
  
                          # Drop trailing newline while editing.
                          # (prompt-toolkit doesn't enforce the trailing newline.)
                          if text.endswith('\n'):
                              text = text[:-1]
                      except Exception as e:
                          self.editor.show_message('Cannot read %r: %r' % (location, e))
                          return ''
                      else:
                          return text
                  else:
                      # File doesn't exist.
                      self.is_new = True
                      return ''
  
          self.editor.show_message('Cannot read: %r' % location)
          return ''
docs: Read file I/O backend.