Help fixing so text doesn’t repeat

#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;

int main() {
    srand(static_cast<int>(time(0)));
    int secret = rand() % 10 + 1;
    int guess;

    cout << "Guess a number between 1 and 10." << endl;
    cin >> guess

    while (guess != secret) {
        if (guess < secret) {
            cout << "Too low, try again." << endl;
        } else {
            cout << "Too high, try again." << endl;
        }
    }
    cout << "Correct!" << endl;

    return 0;
}

`