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