Some file I/O code cleanup