summer_2 0 Newbie Poster

The problem I face is since I use this type of loop to achieve the delete function, i really don't know where should i put the "else" statement when the searching result is not found in the file. Because the while loop need to run whether the result is found or not found. Someone pls help me tq!!!

#include <iostream>
using namespace std;
#include <fstream>
#include <cctype>
#include <cstring>
#include <conio.h>
#include<string>

int main() {
    cout << "   Delete Function    " << endl;
    int option;
    string line, name;
    cout << "Please Enter the ID of record you want to delete: ";
    cin >> name;
    ifstream myfile;
    ofstream temp;
    myfile.open("studentrecord.txt");
    temp.open("temp.txt");
    cout << endl;
    int total=0;
    while (getline(myfile, line)) {
        if ((line != name) && !(skip > 0)) {
            temp << line << endl;
        }
        else {
            if (line != ";") {
                cout << line << endl;
            }
            if (skip == 0) {
                skip = 10;
            }
            else {
                --skip;
            }
        }
    }

        cout << endl;
        cout << "You sure you want to delete the following record ?" << endl;
        cout << "[1=Yes]" << endl;
        cout << "[2=No]" << endl;
        cin >> option;
        if (option == 1) {
            cout << "The record with the ID " << name << " has been deleted " << endl;
            myfile.close();
            temp.close();
            remove("PropertyRecord_linebyline.txt");
            rename("temp.txt", "PropertyRecord_linebyline.txt");
            _getch();
            main();
        }
        else if (option == 2) {
            cout << "Press enter to back to menu" << endl;
            _getch();
            main();
        }


}