1. She wrote with a pencil.

2. She wrote in pencil.

3. She is writing a letter in pen.
4. She is writing a letter with a pen.

5. She is writing a letter in a pen.
--------------------------------
Are they all grammatical except #5? Why can't we put 'a' or 'an' after 'in' in each sentence?

1 - 4 are fine.

5 is incorrect. Use 3 instead.

Of the given sentences, sentences 1, 2, 3, and 4 are grammatically correct. Sentence 5, however, is not grammatical.

In sentences 1 and 2, "with" and "in" are prepositions that show the tool or instrument used to write. In this case, a pencil is used for writing. Both sentences 1 and 2 are correct, but they differ in their usage of the preposition.

In sentences 3 and 4, "in" and "with" are also prepositions indicating the tool used for writing. In these cases, a pen is being used to write. Similarly to the first two sentences, sentences 3 and 4 differ in their choice of preposition.

Now, let's address sentence 5. It is not grammatically correct because "in" is not typically used to show the tool or instrument used for writing. Instead, we use "with" or "using" to indicate the instrument, like in sentences 1, 2, 3, and 4.

Regarding your question about the absence of "a" or "an" after "in," it is because "in" is not used to indicate the tool or instrument itself. It indicates the medium or surface that the writing occurs on. In these sentences, the medium or surface is not a pencil or pen, but rather paper or some other writing material.

To summarize, sentences 1, 2, 3, and 4 are grammatically correct because they use the appropriate preposition to indicate the tool used for writing. Sentence 5 is incorrect because it uses "in" to indicate the tool instead of the surface or medium on which the writing is done.