1 John 2:28-29 (ESV)
And now, little children, abide in him, so that when he appears we may have confidence and not shrink from him in shame at his coming.  If you know that he is righteous, you may be sure that everyone who practices righteousness has been born of him.
Everyone who practices righteousness has been born of him. That is born again, born of water and the spirit. See the trick here is that you can’t practice righteousness unless you have been born of him. If you are not born of him, it may look like righteousness, but it is not. But being born of him, and abiding in him, the true practice of righteousness, we practice righteousness, and so we do not hang our heads in shame at his second coming but wait for it with joyful exuberation.