Past Perfect Tense:
Past Perfect is mainly used in such situations, when two actions happened in the past and it may be necessary to show which action happened earlier than
the other. The Simple Past is used in one clause and the Past Perfect in the other.
When I reached the station the train had started.
I had done my home work when Hari came to see me.
I had written the letter before he reached.