I've been reading this book of retreat conferences for priests by Cardinal Burke. In one of the conferences on the sacrament of Reconciliation, the Cardinal speaks about certain special situations. The first is vocational discernment and the second is scruples. Here's the third:
"The third situation is that of the person enchained by a sinful habit. In this case the temptation is not the sin in itself, but the first and more fundamental temptation, the temptation to discouragement. Whereas as good pastors of souls we try to help the penitent to discover the roots of this habit and to heal them, we must first of all help him to not fall into discouragement. Once the penitent becomes discouraged, as Satan well knows, he will remain paralyzed and will no longer succeed in carrying on with his battle against sin. Acts of trust in Divine Providence, the intercession of Our Lady, Refugium Peccatorum [refuge of sinners], and recourse to patron saints are all every effective tools against discouragement." (p. 75)
This resonates with my own experience as a sinner and a confessor. If we are afflicted with sinful habit X, often 'stop doing X' is not the best strategy for our spiritual effort. Often it's better to look at the rest of our life apart from X, in order to (1) avoid the occasions of X, and (2) to find the function of X in our life so as to be able to heal the problem at the root.
As the Cardinal points out, the greatest temptation is the discouragement that makes us despair of ever healing our sinful habit. We give up whatever means are given to us to avoid the occasions of sin, we stop trying to let and abandon ourselves to God's Providence and the prayers of Our Lady and our saintly patrons. This is the danger that is usually much more grave than the acts of the sinful habit itself.