Restructed writeFiles() to use for loop and list.