This belief is based on 1 John 1:9: If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness.
The idea is that the minute we sin, we lose fellowship (are separated) from God until restored by confession and repentance of the wrong we did. A person who theoretically dies between those two points will be eternally lost. The problem with this “doctrine,” is that it allows no room for God’s mercy.
What about sins of ignorance? Have you offended someone and didn’t know it? What makes this less of a sin than one you knew about? The former sin goes un-confessed while the latter is confessed. Note Paul’s words:
I am conscious of nothing against myself, yet I am not by this acquitted; (emphasis mine) but the one who examines me is the Lord. Therefore do not go on passing judgment before the time, but wait until the Lord comes who will both bring to light the things hidden in the darkness and disclose the motives of men's hearts; and then each man's praise will come to him from God. (1 Cor 4:4-5)
John wrote that “God is greater than our heart.” (1 John 3:19) There are things within us that are ugly, which we go to great strides to cover up and excuse. They are just as wrong as the most heinous sins.
God’s mercy and forgiveness is not some mathematical and legalistic formula. We live by the Spirit, not by law, which is the whole theme of Galations. Thank God for His great mercy and lovingkindness.