Fixed issue when flushing log file