This doesn't seem right, did you mean size() - 1 ? I think this reads past the end of the string