I have the following code
You missed two other references to the $file variable, mate, but that's for the better as I think I may've discovered a slightly more efficient method; give this a try:
\n"; } } closedir($handle); } ?>