Fix bug opening files in directories with subdirs