He brought a pen to write.
You are correct that this does not properly convey the idea that he brought the pen in order to use it for writing. Consider these other examples of the same structure:
He brought a game to play.
He brought a book to read.
When you use a structure like that, the infinitive at the end is something that the noun will be the object of. You play a game, you read a book, but you don't write a pen.
Now, it's true that there's a now generally disagreed-with rule saying not to end a sentence with a preposition. You might work with a boss or a teacher who actually expects people to follow that, and if you don't feel like fighting them on it, you might just want to go along with it. In that case, you would say:
He brought a pen with which to write.
However, for people not stuck to 19th century grammar rules that were essentially arbitrary, there's nothing wrong with:
He brought a pen to write with.
Some people prefer, sometimes, the poetry and rhythm of the "with which to write" version, even if they don't think there's anything wrong with "to write with". You also might choose to do it to produce a more refined impression of your writing. It might also come across as pretentious, so be careful.