added encoding to appendFile