Choose the Correct Form of Verb

When he had come, I ------------a letter.

was writing

am writing

have writing

write