列出来自Dir和First FIle的所有文件,两次使用PHP列出

I am listing all the files in a dir with php but the first file is being listed twice.

Also there was a %20 being added to the url when the link was clicked. It appeared right before the username when being added to the url path to download and then it went away without any changes being made to my script.

Any ideas what would cause this type of behavior?

<?php
$directory = 'downloads/username';

$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));

while($it->valid()) {

    if (!$it->isDot()) {
?>
       <a href="https://www.example.com/site-dev/downloads/<?php echo $current_user->display_name . '/' . $it->getSubPathName() . '">'?>
       <?php echo $it->getSubPathName() . "</a><br>";
        // echo 'SubPath:     ' . $it->getSubPath() . "<br>";
        // echo 'Key:         ' . $it->key() . "

";
    }

    $it->next();
}
?>