fixed bug that printed empty sequence when counter equals sequence length