Is there any method to read from file line by line?

I want to create an edit function, the flow is
In a loop, read the next record until there are no more records.
If we found the record we want:
Write the new data to the output file
else
Write the old data to the output file
end loop
Close the input and output files, erase the input file and rename the output file.

I have try while(getline(file,line)) and while(!file.eof()) but both of it not able to read the content i wrote in the txt :
I want when the user key in want to edit property type, if found "propert type" word, then rewrite the file but i have tried many time still not able to read the word

Property type : Single-storey House
Landlord name : Jason Chee
Property address: No 2, Jalan SB Besar 1/1,

i would like to ask is they any method to solve it

How to print error message when the search result is not found in file(c++)

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();
        }


}