fix iterating through paths that have spaces in them

Fixes #344, #196