refactoring, warn about unclosed file if pointer is overwritten