Fixed writing to the log files