Those sentences are very complicated and not well suited to ELL. To best answer your question, I'll focus on the specific clauses you've wrapped in stars.
Each of these clauses uses a different tense of the verb "write".
I had been writing.
The first clause is using the past perfect progressive. This tense communicates specifically that the writing had a duration. In your overall sentence, this carries the greater meaning that your realization of the fact grew progressively during the process of writing.
The second clause is using the past tense. It just means that at some time in the past, you wrote. When using this tense, you are not putting any emphasis on the duration of your writing. This might be appropriate for the sentence you used as an example, since it was writing the letter that helped you develop your understanding. But it might not be appropriate for all sentences.