file is good in c++

# Reading from a File in C++

#include <iostream>
#include <fstream>
#include <string>

int main() {
    std::string line;
    std::ifstream file("example.txt");

    if (file.is_open()) {
        while (std::getline(file, line)) {
            std::cout << line << std::endl;
        }
        file.close();
    } else {
        std::cout << "Unable to open file" << std::endl;
    }

    return 0;
}