moved log file opening