diff --git a/Testing/Code/OBIA/otbMinMaxAttributesLabelMapFilter.cxx b/Testing/Code/OBIA/otbMinMaxAttributesLabelMapFilter.cxx
index 597ae1132cfba2fed9c0ef266c05aa0cad3eb664..40384f762776b2d85ebb373a4c4229720260ca62 100644
--- a/Testing/Code/OBIA/otbMinMaxAttributesLabelMapFilter.cxx
+++ b/Testing/Code/OBIA/otbMinMaxAttributesLabelMapFilter.cxx
@@ -95,6 +95,7 @@ int otbMinMaxAttributesLabelMapFilter(int argc, char * argv[])
     outfile << "  " << (*it).first << " : " << (*it).second << std::endl;
     }
   outfile << std::endl;
+  outfile.close();
 
   return EXIT_SUCCESS;
 }