Clarification wanted: Let $T$ be the set of all infinite sequences of $0$'s and $1$'s with finitely many $1$'s. Prove that $T$ is denumerable. I think I'm misunderstanding the following proposition.

Let $T$ be the set of all infinite sequence of $0$'s and $1$'s with only finitely many $1$'s. Prove that $T$ is denumerable. 

I'm also given the following lemma to use:

Let $\{A_{i}| i\in\mathbb{N}\}$ be a denumerable family of finite non-nonempty sets which are pairwise disjoint, then $\bigcup _{i\in\mathbb{N}}A_{i}$ is denumberable. 


I'm not quite seeing how adding the condition that there are finitely many $1$'s makes this the set $T$ countable, since there is still a possibility of infintely many $0$'s. It still looks susceptible to the diagonalization argument. 
Could anyone clear up why the the set is countable? 

For $b=(b_n)_{n\in N}\in T,$ if $b_n=0$ for all $n,$  then $f(b)=0.$ 
If $m_0$ is the least $n$ such that $b_n=1,$ and $m_1$ is the largest $n$ such that $b_n=1$  then $$f(b)=(2^{m_0-1})\sum_{j=0}^{m_1-m_0} b_{m_1-j} 2^j.$$ Then $f$ is a bijection from T to the non-negative integers. 
The idea is to interpret $(b_{m_0},...,b_{m_1})$ as the base-two representation of an odd number $g(n)\in N,$ and let $ 2^{m_0-1} g(n)=f(n).$
An attempt to use a diagonal argument to try to prove that $T$ is uncountable will produce a binary sequence with infinitely $1$'s, which is not in $T$.
