Fixes a bug in the way file names are written to the filesArray. Introduces new bug in having populating the array