Counting Characters from an HTML File with Python
I don’t have enough reputation to comment, so I must say this in an answer.
It looks clunky to use
    while x == 4:

and then do
    x = 3

whenever you want to break out of the loop.
It looks better to do
    while True:

and when you want to break out of the loop do
    break

Cheers!