Fix for log files not writing correctly