code: def write_omega_scan_config(channellist, fobj, header=True):
      if isinstance(fobj, FILE_LIKE):
          close = False
      else:
          fobj = open(fobj, 'w')
          close = True
      try:
          if header:
              print('
              print('
          group = None
          for channel in channellist:
              if channel.group != group:
                  group = channel.group
                  print('\n[%s]' % group, file=fobj)
              print("", file=fobj)
              print_omega_channel(channel, file=fobj)
      finally:
          if close:
              fobj.close()