コーヒーを飲みながら、手紙を書いた。Now, while I understand the Japanese sentences, the English sentences seem to me flipped around. I see the use of "while" to refer to the first action, with basically the first action happening only during the timeframe of the second action; just like in Japanese, I feel that in English (and Swedish) the focus in the sentence lies on the second action. So in the first example, if going by the English translation in the book, the character was sitting down to drink coffee, and just started to write a letter as a side-thing.
I wrote a letter while drinking coffee.
I went to university while doing a part-time job.
I did a search for the word "while" and came across this informative Wikipedia entry, which says the primary meaning is "during the time that". Now, with that in mind, let's see the example sentences from the book again, with "while" replaced with the whole phrase.
I wrote a letter [during the time that I was] drinking coffee.I think that it becomes clearer there how the 'weight' of the action lies on the second part.
I went to university [during the time that I was] doing a part-time job.