I've run into a situation where getline returns the entire file. I have not had the problem before and could not find a solution to this online. When I open my input file in textwrangler it reads the file correctly, with new lines at the end of each line. However, my call to getline returns the entire file instead of just the first line.
Any ideas of where I should look? Might it be the wrong kind of new line? Perhaps there is something about iostream that I do not understand?
It's always possible that textwrangler will display the correct line endings where as something that actually shows you the line endings, like MSWord or Notepad++, will show you the true line endings. Also remember, word wrapping isn't actual line endings. However, stream objects don't differentiate between line endings, or else it wouldn't be portable, I believe.
Your code snippet and the text file may help to alleviate the issue, however, the line endings might change during a copy/paste. Another suggestion would be to try redownloading/retyping/copying to a new file the one that's having issues, also try using a file that you know is good and see if you have the same issues.
Your thinking was right along the lines of what I was thinking. Textwrangler has an option to show invisible characters which indicates that a line ending is indeed at the end of the line.
I have run the code with other files and it works fine. Are there only certain types of line endings which are pulled into the stream or which getline recognize?
The relevant code is the opening of a file and then a call to getline.
Ugh, this internet, I swear. Anyways, 0A translates to '\r', not '\n' as many people think. If the file originated from Windows and has DOS endings, the next character in the file should be '\n' or 0D. getline has a third parameter called the delimiter. You can specify the last character to read by passing a character. To more or less debug your code, try switching this to ',' or '\r'.
Another thought is that you have the code you pasted innocently wrapped inside of a loop of some sort, multiple calls to the same function, goto/labels, while/for loop, etc. I'd suggest sharing a few more lines with us so we can get to the bottom of this. Something is horribly amiss.