You've got only half the message about sin that John was teaching the church. Here's the extract where he first introduces his concern about sin in the church
This is the message we have heard from him and proclaim to you, that God is light and in him there is no darkness at all. If we say that we have fellowship with him while we are walking in darkness, we lie and do not do what is true; but if we walk in the light as he himself is in the light, we have fellowship with one another, and the blood of Jesus his Son cleanses us from all sin. If we say that we have no sin, we deceive ourselves, and the truth is not in us. If we confess our sins, he who is faithful and just will forgive us our sins and cleanse us from all unrighteousness. If we say that we have not sinned, we make him a liar, and his word is not in us.
There are two main statements in this. The first, as you say, is that anyone who has fellowship with Christ does not sin. You can't mix darkness and light. The second is the reality that only the self-deceived in the church say they have no sin.
John is deliberately putting these contradictory statements together.
It's clear from later on in the passage that deceivers had entered the church and thrown the believers into confusion with false teaching. From the content of the letter, it's reasonable to believe that it was their teaching about sin that caused the problems. Perhaps 'immorality doesn't matter if we live by grace' or something of that nature.
So first is the clear teaching that a sinning Christian is a living contradiction. You can't belong to the light yet walk in darkness. Second is the reality that we miss the mark all time.
The good news - the way out of the contradiction - is Jesus himself
My little children, I am writing these things to you so that you may not sin. But if anyone does sin, we have an advocate with the Father, Jesus Christ the righteous; and he is the atoning sacrifice for our sins, and not for ours only but also for the sins of the whole world.
So we must urgently deal with sin wherever we find it in ourselves. And we can trust Jesus whenever we fall short.
The other major theme in the letter is the command for the brothers and sisters to love one another. These two concerns take up almost the whole content of the letter.
This is the message we have heard from him and proclaim to you, that God is light and in him there is no darkness at all. If we say that we have fellowship with him while we are walking in darkness, we lie and do not do what is true; but if we walk in the light as he himself is in the light, we have fellowship with one another, and the blood of Jesus his Son cleanses us from all sin. If we say that we have no sin, we deceive ourselves, and the truth is not in us. If we confess our sins, he who is faithful and just will forgive us our sins and cleanse us from all unrighteousness. If we say that we have not sinned, we make him a liar, and his word is not in us.
There are two main statements in this. The first, as you say, is that anyone who has fellowship with Christ does not sin. You can't mix darkness and light. The second is the reality that only the self-deceived in the church say they have no sin.
John is deliberately putting these contradictory statements together.
It's clear from later on in the passage that deceivers had entered the church and thrown the believers into confusion with false teaching. From the content of the letter, it's reasonable to believe that it was their teaching about sin that caused the problems. Perhaps 'immorality doesn't matter if we live by grace' or something of that nature.
So first is the clear teaching that a sinning Christian is a living contradiction. You can't belong to the light yet walk in darkness. Second is the reality that we miss the mark all time.
The good news - the way out of the contradiction - is Jesus himself
My little children, I am writing these things to you so that you may not sin. But if anyone does sin, we have an advocate with the Father, Jesus Christ the righteous; and he is the atoning sacrifice for our sins, and not for ours only but also for the sins of the whole world.
So we must urgently deal with sin wherever we find it in ourselves. And we can trust Jesus whenever we fall short.
The other major theme in the letter is the command for the brothers and sisters to love one another. These two concerns take up almost the whole content of the letter.