That's the whole idea. You're going to fail from time to time, but as long as you come to God with a repentant heart (as David did after his affair with Bathsheba), you will be forgiven.
1 John 1:9 If we confess our sins, he is faithful and just to forgive us our sins, and to cleanse us from all unrighteousness.
Paul struggled with the same thing:
Romans 7:14 For we know that the law is spiritual: but I am carnal, sold under sin. 15 For that which I do I allow not: for what I would, that do I not; but what I hate, that do I. 16 If then I do that which I would not, I consent unto the law that it is good. 17 Now then it is no more I that do it, but sin that dwelleth in me. 18 For I know that in me (that is, in my flesh,) dwelleth no good thing: for to will is present with me; but how to perform that which is good I find not. 19 For the good that I would I do not: but the evil which I would not, that I do. 20 Now if I do that I would not, it is no more I that do it, but sin that dwelleth in me.