Revert "Use forEach instead of for loop. Remove checking if files[0] exists"

This reverts commit b8a7880b7b9d28b0b26622288db684f561738d56.