As an alternative without the problem of spaces (POSIX):

    $ sed -n '$=' ~/myfile.txt

Captured in a variable:

    $ nl=$(sed -n '$=' ~/myfile.txt)
    $ echo "1-$nl-"
    1-100-

Note that sed counts the last line even if it doesn't end in a newline character (as it should in a properly formatted text file). More generally, sed may fail to print the number of newline characters in non-text files.

---
Another alternative:

    $ nl=$(grep -v . ~/myfile.txt | tr '\n' 'x')
    $ echo "1-${#nl}"
    1-100

Note that grep will also print invalid characters (additionally to newlines) in the locale used.