created a log to file function