added logging to WriteToFile Method.