Fixing fileIO memory leak