Fixed wrong handling of `cwd` parameter

When passing the `cwd` parameter to copy the target file list is built correctly but the actual copying fails, this patch fixes this.