'Read .csv function only reading first line

This following code is only reading the first value of the .csv file (3.9)

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>

void read_train() {
    std::ifstream read("test.csv");
    std::vector<double> store;
    std::string line;
    while (getline(read, line)) {
        double x;
        x = std::stod(line.c_str());
        store.push_back(x);
        std::cout << x << std::endl;
    }
    read.close();
}

int main() {
    read_train();
}

Below is the .csv file:

3.9
37.3
0
14.1
8
16.3
29.1
16.1
18.3
0

Thank you very much for assisting!



Sources

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

Source: Stack Overflow

Solution Source