fix write logfile