added log.txt output functionality