Fix issue with writing to log file when not suppose to