Added log file flushing