The function works fine for 13 characters but then stops even if there is more to read. Right now, test.txt has in it, "abcdefghijklmnopqrstuvwxyz" but getline only gets, "abcdefghijklm". What is going on?
I added a cout statement and it gave me "45". I assume this to be a trash value. I tried changing my loop condition to data[i-1] but then it acted like an infinite loop. Then I figured out that the problem was in my input file. I forgot to add the newline on the end. *facepalm*. The loop condition still needs to be data[i-1] though. Thank you for your help!