Is this the proper way to count the number of newlines in a file?

I feel like there is a better way to read the newline and count it instead of using .get(), but im not sure
image.png
Was this page helpful?