docs: def writef(notebook, nb_file, fmt=None):
      """Write a notebook to the file with given name"""
      if nb_file == '-':
          write(notebook, sys.stdout, fmt)
          return
  
      _, ext = os.path.splitext(nb_file)
      fmt = copy(fmt or {})
      fmt = long_form_one_format(fmt, update={'extension': ext})
  
      create_prefix_dir(nb_file, fmt)
  
      with io.open(nb_file, 'w', encoding='utf-8') as stream:
          write(notebook, stream, fmt)