Made a significant improvement in logging by keeping the log file open.