"The righteous falls seven times and rises again, but the wicked stumble in times of calamity" (Proverbs 24:16).
Here is a Scriptural definition of righteousness that doesn't mean moral perfection, but does mean being right before God. The verse partly describes those who don't succeed at first, but try, try again. But it would also apply morally. The Bible says no one is without sin (Ecclesiastes 7:20), but it also describes Noah and Job and David and Daniel as blameless. This verse explains the natural question that arises.
It isn't that they never failed. It's that they kept on repenting.
It isn't that they never fell short. It's that they kept on persevering in the Lord.
Keep on keeping on...