which one is grammatically correct and why
I wrote a book when I was in USA
I had written a book when I was in USA
postman bought a letter. It was given to your mother.
postman bought a letter.It has been given to your mother.