caf: use #for instead of #while. break if #uploading fails

#while reads input from #stdin, and #ssh also reads from #stdin. After
the first #while entry, the rest of #stdin will come to #ssh ;)

we will not execute #ssh command if the previous #upload step fails.