Fixed a bug where if the file could not be written then lots of write and flush
calls will fail in the logger.