code changes for writing the logs to a file.