Hmm, it might be worth trying to see if perhaps there's something sneaking into the array with the paths that shouldn't be there- but I've displayed every element in the array before and it looks okay. I'm also not running mkpath when a directory already exists.