open logfile before writing to it