Polling for existence of file on remote host

I am polling a file on remote host. I have this code that works, but can't explain why it works.

while [ -f `ssh user@remote.no-exist.com 'ls /user/app1/.done'` ]
do
  echo [INFO] Sleeping for 5 secs
  sleep 5;
done

This code works in the way that when the .done file exists on the remote host, the script comes out of the while loop. When the .done is not there, it sleeps for 5 secs and checks again.

Reading the code, it seems like if the file exist on the remote host, the ssh will return the path to the file as output with rc=0, which then should get evaluated on local host for existence of a regular file. That file never exists on the local host. I find it strange that it is working and need help in understanding what is making it work. I am on RHEL 5 x86_64.

Thanks in advance!
:wall:

while true
do
  ssh user@remote.no-exist.com 'ls /user/app1/.done' > /dev/null 2>&1
  if [ $? -eq 0 ] ; then
      echo "the job is done"
      exit
  else
     echo [INFO] Sleeping for 5 secs
     sleep 5;
  fi
done