implement writing to log file