Bugfix: closing the file only it it was opened.
The requested path should not leave the base path.