Unexpected behaviour from DirectoryIterator