Added check for logfile existence