當他進來的時候, 我正在寫信。

I was writing a letter when he came.

Source: Tatoeba

Sentence Composition