Added proper handling of filenames with spaces