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 and walk in darkness. Now, don't be deceived about this. Many people are deceived on this score; they think that they have fellowship with God but they are walking in darkness, and that is an impossibility.