SplFileInfo can't be used on directories, so using ->offsetExists() instead for the test.