let print_file ?encoding file ch =
  let oc = open_out file in
  let fmt = Format.formatter_of_out_channel oc in
  print_group ?encoding fmt ch;
  Format.pp_print_flush fmt ();
  close_out oc