fixed error with logfile write