Matthew 6:12,14-15 says we are supposed to ask God to forgive us and be willing to forgive others. If we don't, God won't forgive us.
What Does it Mean? God knows when we fail and he is willing to forgive us, but we also need to forgive others when they hurt us. Life is full of hurts, we hurt others, they hurt us. 1 Corinthians 13:5 says we are not to keep a record of wrongs, ours or theirs. God forgives us and he doesn't keep track of how many times we fail. Neither should we, even if we are the one culprit. Be patient with yourself; God is. We are told to forgive, that means to forgive ourselves too. Don't try to punish yourself. Ask God to help you stop making the same mistake over and over. Look for ways to avoid the temptation, practice rejecting the thought, and ask your friends to pray. James 5:16 says we should confess our sins to each other and pray for each other so that we can be healed. Don't tell the whole world, but choose one or two close friends to share your heart and ask them to pray. Get into the habit of praying together for each other.