Improved file handling for logger class.