non leaking resources management when files are opened