I've been having such a difficult time trying to "delete" a line from a text file and have looked everywhere. I'm a beginner with C++ so I have no idea how to use vectors yet.
When I run this program, it will not write anything to the tempFile. Am I missing something?
    string deleteLine, line;
    ifstream addressFile;
    addressFile.open("AddressBook.txt");
    ofstream tempFile;
    tempFile.open("temp.txt");
    int i = 1;
    while (getline(addressFile, line)) {
        cout << (i++) << " " << line << endl;
    }
    cout << "Which line do you want to remove?" << endl;
    cin >> deleteLine;
    // GOOD UP TO HERE
    while (getline(addressFile, line)) {
        if (line != deleteLine); {
            tempFile << line << endl;
        }
    }
    tempFile.close();
    addressFile.close();
    remove ("AddressBook.txt");
    rename ("temp.txt", "AddressBook.txt");
    cout << endl << endl;
Update - This is the current code I have and still not writing to tempFile
    ifstream addressFile;
    addressFile.open("AddressBook.txt");
    ofstream tempFile;
    tempFile.open("temp.txt");
    string line;
    int lineNum, i;
    i = 1;
    while (getline(addressFile, line)) {
        cout << (i++) << " " << line << endl;
    }
    addressFile.seekg(0);
    cout << "Which line number do you want to remove?" << endl;
    cin >> lineNum;
    // GOOD UP TO HERE
    i = 1;
    
    while (getline(addressFile, line)) {
        if (i++ != lineNum) {
            tempFile << line << endl;
        }
    }
    tempFile.close();
    addressFile.close();
    //remove ("AddressBook.txt");
    //rename ("temp.txt", "AddressBook.txt");
    cout << endl << endl;
 
    