I think the problem is with your string and the Match Pattern. Your input string sometimes has \r\n to indicate a new line, and sometimes \n. In your Match Pattern you're just searching for \n and passing the "before" string to the "Get Text Rect" VI. In the cases where you have a \r\n at the end, the "Get Text Rect" VI gets a string with \r at the end, which is displayed as a newline in a string, thus it will output a "bottom" of 26 instead of 13 (i.e., two lines), leading to extra space at the bottom since all you're doing is adding up the heights from each iteration.