           (delete-file file-name))
       (bitbucket/update-project-keys username password)
       (dolist (project
-               (mapcar (lambda (p) (replace-regexp-in-string ":.*" "" p)) (bitbucket/get-project-keys)))
+               (mapcar (lambda (p) (replace-regexp-in-string ":.*" "" p)) (bitbucket/get-project-keys project-file)))
         (let ((repo-buffer (url-retrieve-synchronously (concat bitbucket/url-rest-api "projects/" project "/repos?limit=1000"))))
           (if repo-buffer
               (progn

                  (insert clone-commands)
                  (insert "\n")
                  (write-region (point-min) (point-max) file-name t)
                  (kill-buffer)))))))))

(provide 'bitbucket)


                        ))
                    ))))

(defun bitbucket/create-clone-script (out-dir project-file username password)
  "Create Bitbucket clone script in OUT-DIR for all repositories.  USERNAME and PASSWORD are used for authentication."
  (interactive
   (list
    (read-directory-name "Output dir: ")
    (read-file-name (concat "Project file: (" bitbucket/project-keys-file "): ") (expand-file-name "~") bitbucket/project-keys-file t (replace-regexp-in-string ".*/" "/" (expand-file-name bitbucket/project-keys-file)))
    (read-string (concat "Username (" bitbucket/default-username "): ") nil nil bitbucket/default-username)
    (read-passwd "Password: ")))
  (let ((file-name (concat (if (string-suffix-p "/" out-dir) out-dir (concat out-dir "/")) "clone-script.sh"))
