Fixed using a directory for $target.  More general testing needs to be done, but things are looking good.