I have a file containing the sentence "Hallo, my name is Max". I have tried printing it on the Command Prompt, it printed "Hallo, my name is Max Max". What I don't understand is why did it print "Max" two times and not one?
#include<iostream>
#include<string>
#include<fstream>
int main(){
    std::string str;
    std::ifstream myfile("text.txt");
    while(myfile){
    myfile >> str;
    std::cout <<str<< " ";
    }
    myfile.close();
    return 0;
}
