If the above is the case, then this has already been solved for the most part. See this post and this post. Basically, using regex, convert the input into a list of strings using carriage return as the delimiter; and the number of lines will be the list item count.
If you need to take into account lines created by soft wrapping, then that’s a whole different animal, and nothing comes to mind right off the bat.
-Steve