Write error stack trace to file