change awk gensub variable and check if logfile is writeable