diff --git a/src/plugins/metrics/metrics_cilast.ml b/src/plugins/metrics/metrics_cilast.ml
index 8c737e2c13e7a7f25666c6870d107b7433be8568..bbc73b7f5df2665503791f61581f254e42e9590c 100644
--- a/src/plugins/metrics/metrics_cilast.ml
+++ b/src/plugins/metrics/metrics_cilast.ml
@@ -745,7 +745,8 @@ let compute_on_cilast ~libc =
          | Text -> pp_with_funinfo fmt cil_visitor
          | Json ->
            let json = json_of_funinfo cil_visitor in
-           Yojson.pretty_print fmt json
+           Yojson.pretty_print fmt json;
+           Format.fprintf fmt "@." (* ensure the file ends with a newline *)
         );
         close_out oc;
       with Sys_error _ ->
diff --git a/tests/metrics/oracle/libc.json b/tests/metrics/oracle/libc.json
index 5f7f5afbe20178035e1de51267e1ba2ef1acce15..beaef667824195860e65dd80e77a5ed91e266313 100644
--- a/tests/metrics/oracle/libc.json
+++ b/tests/metrics/oracle/libc.json
@@ -138,4 +138,4 @@
     "__fc_stdout", "__fc_ttyname", "optarg", "opterr", "optind", "optopt"
   ],
   "entry-points": [ "f", "main" ]
-}
\ No newline at end of file
+}