It is true that sin puts up a barrier between us and God, and cuts us off from the fellowship He wants us to have with Him. The Bible says, "But your iniquities have separated you from your God; your sins have hidden his face from you, so that he will not hear" (Isaiah 59:2).
But this doesn't mean God cuts us off and refuses to have anything more to do with us - not at all. He wants us to come back to Him and have our fellowship with Him restored - and He does everything He can to wake us up and bring us to repentance. Sometimes the only way He can do this is by making us so miserable that we finally realize what we've done and turn back to Him. Sometimes He quietly shows His love to us even when we don't deserve it, hoping to awaken us to His goodness.
One way to see this is to think about what happens in a family when someone wrongs another member of the family. That person is still a member of the family; nothing can change that. But a barrier has come between them and the rest of the family; their fellowship has been broken. The only way back is confession and forgiveness. The same is true with us.
Don't let sin come between you and God. God loves you, and Christ died to take away our sins. When we do sin, however, we need to confess it and seek God's forgiveness at once. The longer it goes on, the more the devil rejoices.