fixed bug when reading files with garbage before or after path.