Fix file scan

Now also works if there is a file (e.g. `chapter1.tex`) with the same name as a project subdirectory (e.g. `chapter1`). 

Before, the file scanner would return the directory name instead of the file name.