Changed FileHandler for loop in writeFile()