Bohumil Hrabal said this quote

Writing is a defence against boredom, but it's also a cure for melancholy.