Added writing log to file