Why the file is read as empty?

Have main.cpp and input.txt.
Code like this:

spoiler
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <iterator>



using namespace std;

string getResult(vector<string> val) {
 bool flag = true;
 for (int i = 0; i < val.size(); i++) {
 // Iteration
 string current = val[i];

 for (int j = 0; j < current.size(); j++) {
 if (current[j] != '') {
 // If first word is uppercase
 if (flag && isupper(current[j]) == 0) {
 current[j] = toupper(current[j]);
 val[i] = current;
}
 flag = false;
}
}
 flag = true;
}

 string result;
 for (int i = 0; i < val.size(); i++)
 result += val[i] + ".";

 return result;
}



int main() {
 ifstream file("input.txt");
 string str;
 string file_contents;

 if (!file.is_open()) {
 cout << "Some problems with file...";
 return -1;
}



 while (getline(file, str)) {
 file_contents += str;
file_contents.push_back('\n');
}

 vector<string> array;

 // split
 istringstream is(str);
 string s;
 while (std::getline(is, s, '.'))
array.push_back(s);

 cout <<"Current input: "<< str << endl;

 string result = getResult(array);

 cout << "After:" << result << endl;
 return 0;
}</string></string></iterator></vector></sstream></fstream></iostream>


Run it:
$: g++ -o prog main.cpp
$: ./prog


Get:
Current input: 
After:


A feeling as if the file is empty, and it is not empty. The file is in the same folder main.cpp. What's the problem?
June 5th 19 at 21:21

Find more questions by tags C++