Option 1 -> Simple past tense doesn't convey an action in progress at the time of another past action.
Option 2 -> Simple present tense doesn't match with "entered" (past tense) and breaks temporal consistency.
Option 3 -> Present continuous tense is incompatible with "entered" (past tense) in the same sentence.
Option 4 -> Past continuous tense correctly indicates an ongoing action that was interrupted or happening when the Principal entered.
Hence, 4. was writing -> When describing two past actions where one was ongoing when the other occurred, we use past continuous (was/were + verb-ing) for the ongoing action and simple past for the interrupting action -> correct