Psalms 119:67 (KJV)

Before I was afflicted I went astray: but now have I kept thy word.