Need a professional eye to look at this

This code should be complete but I cant get it what the problem is. It is a very strange thing that happening. I might need a professional eye to see if the problem could be found :)
The problem is this:

The mainthing is that I am using a for loop to go through 5 .txt file paths that I have read in into a vector called: "ReadInGroup" from a .txtfile (NewDataGroup.txt)
The lines in this file NewDataGroup.txt look like this, so this should be correct:

Now is the funny this. The while loop reads in the path-lines in the vector as it should do. This works!
(Below I also have the 5 paths between /* */

So the for loop should now loop through one file at a time and read these files and a little futher down in the code I use a while loop to read in all data in these files into a vector.The for loop goes through the 5 files above though I have used a messagebox to confirm it before.
The funny here is that the for-loop goes through the 4 first files above very fast, then stops at the last file(Hello5.txt) and do read in this files data into a vector. (Why the last file, very strange ? This meens it works in a way)

Now, I have specified manually the filenames/paths below between /* */
(Hello1.txt - Hello5.txt) as a test to see what happens ?
So if you take these /* */ away, this will mean that the already read in vector ReadinGroup will replace with the manually specified paths as I have done below.

If I do this, then it goes through all 5 files and read all 5 files into the vector as it should do.
So the code is correct done but something is missing.

What is the difference, Why does it work when I manually specify the pathway to the files and not when I have read them in, into the vector.
In both cases the for loop will read from the same 5 elements.
I really have no clue on this one.

I realize you didn't post all your program, but what do you do with the vector ReadInData that is declared inside that for loop ? The entire vector is destroyed on each loop iteration and you do nothing with it but toss it into the bit bucket.

Thank you. You are right about I didn´t post all code, there is a part missing at the bottom where I put the vector ReadInData contents to a file.

Yes I do declare: std::vector<string> ReadInData;
in the foor-loop and after putting the contents to the output file, I clear the vector like this: ReadInData.clear();
I dont know if this is okay to do though as I want the ReadInData to be emty after each loop as each loop will read in new data from a new .txt file, so I need it to be emty.
I dont know if this info helps, if you want me to post the entire code, I will do that.
Thank you... !

I realize you didn't post all your program, but what do you do with the vector ReadInData that is declared inside that for loop ? The entire vector is destroyed on each loop iteration and you do nothing with it but toss it into the bit bucket.

You don't have to specifically clear the vector because it will be destroyed and recreated on each loop iteration. Just wasting cpu cycles to clear it yourself.

>>foor-loop
Its spelled for-loop. There is no such word as foor, other than as a proper name. :)

>>What is the difference, Why does it work when I manually specify the pathway to the files
My guess is that the files are not where you expect them to be. After opening a file call the is_open() function to see if the open succeeded. I'll bet it failed. Carefully compare the files and their paths in NewDataGroup.txt with those you hard-coded in the program.

Yes, "for-loop" ofcourse :). I will not clear the vector then. So now I know that it clears itself after each for-loop, thanks for that info.
I am not really sure how to use is_open().
Though I looked really carefully about the path between the hardcoded and what I have in the NewDataGroup.txt.

I tried to change so the ReadInGroup red in the hardcoded pathways and the for-loop went through all 5 five files as it should.
The second line in the example below is the hardcoded one.
The first is the line from the file. I beleive these should be the same.

If I change so it reads in the lines from NewDataGroup.txt it will not work except for the last file. ?
The files are in the right folder, I am 100% of this as the hardcoded example works and the last file from the NewDataGroup.txt.

It confuses me really :) I understand that it is difficult to know where the problem is also.

You don't have to specifically clear the vector because it will be destroyed and recreated on each loop iteration. Just wasting cpu cycles to clear it yourself.

>>foor-loop
Its spelled for-loop. There is no such word as foor, other than as a proper name. :)

>>What is the difference, Why does it work when I manually specify the pathway to the files
My guess is that the files are not where you expect them to be. After opening a file call the is_open() function to see if the open succeeded. I'll bet it failed. Carefully compare the files and their paths in NewDataGroup.txt with those you hard-coded in the program.

This is All contents in NewDataGroup.txt, (there is no more lines than this)
These 5 lines is red in into the ReadInGroup vector wich also works great with the while loop.
(The last line will work in the for-loop but the other lines just goes through with the for-loop very fast without reading in the data from the files.)

Thank you Ancient Dragon, i have XP and I did run the code and received "Error opening file" on the first 4 files.
I will try to just experiment around and see if something can be solved, perheps otherwise I can post a complete code some other time.
Strange though if the files dont open but the last one does.
Thanks for your help :)

Next step: display the name of the file that it is attempting to open, then compare it with what you think it should be. There is obviously something wrong with it. Even one mis-placed space will make a difference.

Yes, this was actually the first thing I did. I will do this again but more carefully.
I will check out every small detail and see what I will get out of it. Perheps change the filedestinations also etc for testing.
Thank you again!

Next step: display the name of the file that it is attempting to open, then compare it with what you think it should be. There is obviously something wrong with it. Even one mis-placed space will make a difference.

A minor note .. why are you skipping the ReadInGroup[] at index 0?
In your for loop, you start at index 1 instead of 0, so that leaves the first
index of ReadInGroup[] unprocessed.
Is that what you want, or should you change

I did solve the problem. Though I dont exactly know the difference I have done.
I did not post this code and there for ofcourse impossible to know about the problem.

The thing was that I browsed a directory for .txt files that appeard in a textBox.
From here I just put all contents in this textBox to: textBox1->Text->ToString();

And this I did put to ofstream(OutPutFile <<) and it looked exactly the same with spaces and new lines as this code below that do works now.
So it must be a difference between these. Even that the output look exactly the same.
So the while-loop that after this read from the file, do read in everything correctly.