I'm not getting any errors, just an infinite loop! Here's my code:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<fstream>
#include<assert.h>
using namespace std;
inline void keep_window_open() { char ch; cin >> ch; }
int main() {
    int sum{ 0 }, number;
    vector<int> numbers;
    string word;
    fstream file;
    file.open("file1.txt", fstream::in);
    while (true) {
        file >> number;
        if (file.eof()) {
            numbers.push_back(number);
            break;
        }
        else if (file.fail()) { file >> word; }
        else if (file.bad()) exit(1);
        else numbers.push_back(number);
    }
    for (int x : numbers) sum += x;
    cout << sum << "\n";
}
The file I am reading from:
words 32 jd: 5 alkj 3 12 fjkl 23 / 32 hey 332 2 jk 23 k 23 ksdl 3 32 kjd 3 klj 332 c 32
 
     
    