Writing to log file working