Error Permission denied when reading directory

Hello. I’m progressing through some code to open read and retrieve info from files in a directory and using file_get_contents with a foreach statement I am getting this error on the final directory in the path. The code is opening the directory and returning the links within the index.html file as expected but on every attempt I get one error and then the code continues. Any ideas on why this is occurring would be greatly appreciated.
Here is the error.

Warning: file_get_contents(f:/wamp/www/contents/video-lectures/lecture-22) [function.file-get-contents]: failed to open stream: Permission denied in F:\\wamp\\www\\sandbox\\clear\\lib\\list_dir.php on line 36

Here is my code.

error_reporting(E_ALL);
global $array_items;
function get_dir_file_array($directory='.', $recursive= false, $include_directories_in_list = true) {
	$array_items = array();
	
	if ($handle = opendir($directory)) {
		while (false !== ($file = readdir($handle))) {
			if ($file != "." && $file != "..") {
				if (is_dir($directory. "/" . $file)) {
					if($recursive) {
						$array_items = array_merge($array_items, get_dir_file_array($directory. "/" . $file, $recursive));
						}
						//this block was returning duplicate urls on the same line, Resulting error failed to stream
						/*if ( $include_directories_in_list ) {
						
							$file = $directory . "/" . $file;
							//print "<strong>$file</strong><br />\
";
							$array_items[] = preg_replace("/\\/\\//si", "/", $file);
						}	*/		
					$file = $directory . "/" . $file;
					$array_items[] = preg_replace("/\\/\\//si", "/", $file);
				} else {
					$file = $directory . "/" . $file;
					//print "<strong>$file</strong><br />\
";
					$array_items[] = preg_replace("/\\/\\//si", "/", $file);
				}
			}
		}
		closedir($handle);
	}
	return $array_items;
}
$files = get_dir_file_array("f:/wamp/www/contents/video-lectures", TRUE);

	foreach ($files as $file=>$filename) {

	    $vid = file_get_contents($filename);

	    if ($vid ) {

	        $h1count = preg_match_all('/(href=")(.*?)(")/i',$vid,$output);
	
	    foreach($output[0] as $key => $val){
  
                $val = preg_replace("/</","<",$val);

                echo "<li>" . htmlentities($val) . "</li>";
        }
        echo "</ul>";
    }else{
        echo "<br/><div class=\\"error\\">No Links found</div><br/>";
    }
	

	}