If we confess our sins, he is faithful and righteous to forgive us the sins, and to cleanse us from all unrighteousness.
You cannot have fellowship with God if you are walking in sin, walking in darkness.