fixed up some code for database.pl. It is able to pass through the loops checking for files with no problem now