code: def split_preserve(string, sep):
      
      # split the whole string into a list so that you can iterate line by line.
      str_list = string.split(sep)
      if str_list[-1] == '':
          # If you split 'this\nthat\n' you get ['this', 'that', ''] if
          # you add newlines to every string in the list you get
          # ['this\n', 'that\n', '\n']. You've just added
          # another newline at the end of the file.
          del str_list[-1]
          str_list = [x + sep for x in str_list]
      else:
          # ['this', 'that'] will become ['this\n', 'that\n'] when
          # mapped. A newline has been added to the file. We don't want
          # this, so we strip it below.
          str_list     = [x + sep for x in str_list]
          str_list[-1] = str_list[-1].rstrip(sep)
      return str_list
docs: split_preserve(string : str, sep : str)  -> [str]
  
      >>> split_preserve('''
      "My dear Holmes, " said I, "this is too much. You would certainly
      have been burned, had you lived a few centuries ago.
                  ''', '\\n')
      ['\\n',
       '    "My dear Holmes, " said I, "this is too much. You would certainly\\n',
       '    have been burned, had you lived a few centuries ago.\\n',
       '                ']
  
      Splits the string and sticks the separator back to every string in the list.