support for filenames with spaces

The current version did not work if there are spaces in the filename.