He is writing to Christians, but he is writing about both we who walk in the light, which is God, and about those who walk in darkness, which is sin.
The Christians had already heard and reacted to what to do about sins...confess them and get washed by the blood of Christ.
John is showing his audience how to identify who is of us and who is not yet of us.
Gracefully, he doesn't slam the door in the face of those still walking in the flesh, darkness, sin; but leaves them an escape.
And he does later add..."We know that whosoever is born of God sinneth not; but he that is begotten of God keepeth himself, and that wicked one toucheth him not." (1 John 5:18)
Those born of God, don't walk in darkness.