These two functions are part of my cpp file. The vector type is of class type (WordInText).
When my program gets into these loops it gets out of it within one loop.
I suspect you want:
You're doing the loop condition the wrong way. Don't compare "less than", instead "not equal". The returned iterators will work like pointers when compared, causing undefined behaviour (i.e. the loop might end any time before reaching the end).
To solve this issue, just compare with "not equal":
When you first enter this method, check if the vector has elements in it.
You should be able to do something like (pseudocode):
if (wordintext_vec.length == 0) or if (wordintext_vec.isnull())
ERROR_LOGIC("Vector is empty");