added example 4: writing errors to a log file