Help me understand if this logic is correct

Create an integer variable i and assign the value as 0.
Create a boolean variable - boolContinueRun and set value as True
You can use a do while loop like below
Do
Increment i variable
Run Query
Get Interim Output
If interim output contains data
Compare and Get Output
Else
Set boolContinueRun=False
End If

             If i=3
                  Send Email provided Output Contains data
                  Set variable boolContinueRun=False
            End if 

While (boolContinueRun=True)

Please check this