How to remove negative numbers from a text file with C++

I’ve got a bunch of data that I need to plot for an assignment in my circuits class, but I only want the positive numbers. It’s a HUGE list, so rather than manually removing the negatives, I figured I’d try to write a program to remove them for me.

I had an intro to programming with C++ course last semester, but we didn’t cover how to read or write to files, so I did a bunch of Googling on how to read from a file in C++ and I wrote code to put the data from the file into a vector, check if each value is positive, put only those values into a new vector and then read out the values in the new vector. Visual studio 2019 found no errors as I wrote the code, but when I try to compile it, it just tells me there are build errors without specifying what they are, so I don’t know what I did wrong. I’m guessing I misunderstood something about how to read from a file — I couldn’t find a single good explanation, so I did my best to synthesize the information from multiple examples I found online.
Here’s my code:


//This programs reads a list of numbers from a data file, removes all non-positive numbers and outputs the list with only the positive numbers
int main()
    std::vector<double> list1;//initial list of numbers
    std::vector<double> list2;//numbers without negatives or zero
    fstream list1file;"C:UsersmblesDesktop3.1 b data file.txt", ios::out);
    int n = 0;
    while (n < 7924)//There are 7925 numbers in the list
        list1file >> list1(i);//read data from file into list1 vector
    for (int i = 0; i < 7924; i++) {
        if (list1(i) > 0){
            list2(i) = list1(i);//write positive numbers into list2 vector
    //fstream list2file;
    //"positive number list", ios::out);
    //int m = 0;
    while (m < list2.size()) {
        std::cout >> list2(m);//output list of only positive numbers 

In case the formatting gets messed up, I also copied it into GDB here: