code: def to_file(self, f, sorted=True, relativize=True, nl=None):
          
  
          if sys.hexversion >= 0x02030000:
              # allow Unicode filenames
              str_type = basestring
          else:
              str_type = str
          if nl is None:
              opts = 'w'
          else:
              opts = 'wb'
          if isinstance(f, str_type):
              f = file(f, opts)
              want_close = True
          else:
              want_close = False
          try:
              if sorted:
                  names = self.keys()
                  names.sort()
              else:
                  names = self.iterkeys()
              for n in names:
                  l = self[n].to_text(n, origin=self.origin,
                                      relativize=relativize)
                  if nl is None:
                      print >> f, l
                  else:
                      f.write(l)
                      f.write(nl)
          finally:
              if want_close:
                  f.close()
docs: Write a zone to a file.
  
          @param f: file or string.  If I{f} is a string, it is treated
          as the name of a file to open.
          @param sorted: if True, the file will be written with the
          names sorted in DNSSEC order from least to greatest.  Otherwise
          the names will be written in whatever order they happen to have
          in the zone's dictionary.
          @param relativize: if True, domain names in the output will be
          relativized to the zone's origin (if possible).
          @type relativize: bool
          @param nl: The end of line string.  If not specified, the
          output will use the platform's native end-of-line marker (i.e.
          LF on POSIX, CRLF on Windows, CR on Macintosh).
          @type nl: string or None