We were opening files but not properly closing them if we returned early with an error condition.
We were opening files but not properly closing them if we returned
early with an error condition.

Problem reported by coverity tool, via Will Cohen

pyrovski/papi,arm-hpc/papi,arm-hpc/papi,arm-hpc/papi,arm-hpc/papi,arm-hpc/papi,pyrovski/papi,arm-hpc/papi,pyrovski/papi,pyrovski/papi,pyrovski/papi,arm-hpc/papi,pyrovski/papi,pyrovski/papi,pyrovski/papi