In 2Corinthians 7:8-13 Paul writes -
8 For even if I made you grieve with my letter, I do not regret it though I did regret it, for I see that that letter grieved you, though only for a while.
9 As it is, I rejoice, not because you were grieved, but because you were grieved into repenting. For you felt a godly grief, so that you suffered no loss through us.
10 For godly grief produces a repentance that leads to salvation without regret, whereas worldly grief produces death.