let dump_scripts file =
  let out = open_out file in
  let fmt = Format.formatter_of_out_channel out in
  try
    Format.fprintf fmt "(* Generated by Frama-C (WP) *)@\n@\n" ;
    Hashtbl.iter
      (fun goal (keys,proof) ->
         Format.fprintf fmt "Goal %s.@\n" goal ;
         (match keys with
            | [] -> ()
            | k::ks ->
                Format.fprintf fmt "Hint %s" k ;
                List.iter (fun k -> Format.fprintf fmt ",%s" k) ks ;
                Format.fprintf fmt ".@\n" ) ;
         Format.fprintf fmt "Proof.@\n%sQed.@\n@." proof ;
      ) scriptbase ;
    Format.pp_print_newline fmt () ;
    close_out out ;
  with e ->
    Format.pp_print_newline fmt () ;
    close_out out ;
    raise e