Therefore to him that knoweth to do good, and doeth it not, to him it is sin.
James 4:17 KJV
What do you know? What have you done upon and with what you know? That gap…between knowing and not doing according to knowledge is sin (unto you). Practical test, I know fire burns, and to avoid been burnt is to avoid fire. If I do not avoid fire, I would get burnt (I…).
Now juxtapose with living righteously: if I know that certain activities are wrong before God and before the moral code of Heaven, and I continue to partake in these activities, they have become sin unto me. As much as you know is as much as you should be accountable.
Even not knowing is out of it because a comforter has been given to us to guide us into “all truth”. Even I John 2: 20 informs us that we have an unction to know “all things”. So if you want to really stay off sin, ask for Grace to do according to what you know and for an open heart to be taught by the Holy Spirit.