'C++ Program Returning Abort Trap

I'm trying to write a C++ that inputs n and then inputs n words. Then I input an s and then print out the n words with s removed. When I try to implement my program, my program says that there is an abort error. Does anyone know why? Thanks a lot.

using namespace std;

int main() {
    int n;
    string words[100];

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> words[i];
    }

    string s; cin >> s;
    for (int i=0; i<n; i++) {
        int n = words[i].find(s);
        words[i] = words[i].erase(n,n+s.length());
    }

    for (int i=0; i<n; i++) {
        cout << words[i] << endl;
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source