code: def write_file(writeFunc, index, existing, x):
      
      # Toil fileStore reference
      if x.startswith("toilfs:"):
          return x
      # File literal outputs with no path, we don't write these and will fail
      # with unsupportedRequirement when retrieving later with getFile
      elif x.startswith("_:"):
          return x
      else:
          x = existing.get(x, x)
          if x not in index:
              if not urlparse.urlparse(x).scheme:
                  rp = os.path.realpath(x)
              else:
                  rp = x
              try:
                  index[x] = "toilfs:" + writeFunc(rp)
                  existing[index[x]] = x
              except Exception as e:
                  cwllogger.error("Got exception '%s' while copying '%s'", e, x)
                  raise
          return index[x]
docs: Write a file into the Toil jobstore.
  
      'existing' is a set of files retrieved as inputs from toil_get_file. This
      ensures they are mapped back as the same name if passed through.