"When I thought of you..." seems to fit better in the English translation :-)
Why 'ter' and not 'meng'?
Ter- here is more to be an accidental verb....so it's just like that she/he suddenly appeared on your mind without you actually trying to think of them
Why not ditulis?
"ditulis'' is a passive form.
"surat ini ditulis oleh saya'' means ''this letter is written by me''.
While ''saya menulis surat'' means "I write the letter''