title: Bash loop a curl request, output to file and stop until empty response
body: <p>So I have the following bash file and right now its looping a curl request based on the for loop.  However, i am tying to find out how to continue looping until the response is empty.</p>
  <p>Unfortunately the API that I am calling is based on pages with a maximum responses of 500 results per page.   I am trying to pull the data since 2017 so its a lot of data.</p>
  <p>I want to continue countering until the response is empty.</p>
  <pre><code>#!/bin/bash
  
  # Basic while loop
  counter=1
  for ((i=1;i&lt;=2;i++));
      do
          curl -o gettext.txt --request GET \
          --url &quot;https://api.io/v1/candidates?page=${counter}&amp;per_page=500&quot; \
          --header 'Authorization: Basic aklsjdl;fakj;l;kasdflkaj'
      ((counter++))
      done
  
  echo $counter
  echo All done
  </code></pre>
  <p>Anyone have an idea?</p>