Hello,
If the thoughts are repetitive, irrelevant, not under your control, causing distress so much that its hampering your day to day life and present for more than a hour you might have OCD. What you are doing i.e., writing is a compulsive behavior and it might help you to get rid of thought for some time. OCD can affect anyone and it can be treated with medication and behavior therapy.
Next Steps
Contact nearby psychiatric clinic for help. Learn how to get rid of these thoughts
Health Tips
Whenever these thoughts come try involving yourself in some other activity or start repeating in your mind 3 times go away. They will subside gradually. Best Wishes.