This closes issue #3 by setting the working dir after each loop