diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py
index e9516e6ab4e2f08291c2eaabc8a49775ae9f7eb1..264f893b35460beabe703fa2c7bbd0e899ecfc14 100644
--- a/modules/icing/pirep_goes.py
+++ b/modules/icing/pirep_goes.py
@@ -609,9 +609,6 @@ def run_qc(filename, filename_l1b, outfile, outfile_l1b):
 
     mask = apply_qc_icing_pireps(icing_alt, cld_top_hgt, cld_phase, cld_opd, cld_mask, bt_11um)
 
-    f.close()
-    f_l1b.close()
-
     bts = []
     phs = []
     opd = []
@@ -643,6 +640,7 @@ def run_qc(filename, filename_l1b, outfile, outfile_l1b):
     data_dct = {}
     for didx, ds_name in enumerate(ds_list):
         data_dct[ds_name] = f[ds_name][keep_idxs,]
+
     lon_c = f['longitude'][keep_idxs]
     lat_c = f['latitude'][keep_idxs]
     time_s = f['time'][keep_idxs]
@@ -658,6 +656,9 @@ def run_qc(filename, filename_l1b, outfile, outfile_l1b):
 
     create_file(outfile_l1b, data_dct, l1b_ds_list, l1b_ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids)
 
+    f.close()
+    f_l1b.close()
+
     return mask