Added whitespace safeguards, simplified path

No it doesn't. 
But it's a must because otherways the loop will be broken if there are any files containing whitespaces.