check filenames before reading them