"But" is a coordinating conjunction. It joins two grammatically equal elements, like phrases or clauses. Because it connects elements, it needs to appear *between* them, not at the beginning of a sentence.
Example:
* Incorrect: But I went to the store.
* Correct: I went to the store, but I didn't buy anything.
However, there are some exceptions:
* In a series of sentences: "But" can be used at the beginning of a sentence that's part of a series, where the previous sentence has already introduced the conjunction.
* For emphasis: Sometimes, "but" can be used at the beginning of a sentence for strong emphasis, but this is less formal and should be used sparingly.
In general, it's best to avoid using "but" at the beginning of a sentence unless you are using one of the exceptions.