Why would you write "ain't"? Isn't it a contraction only used in spoken English?

Solution 1:

"Ain't" is generally pretty stigmatized; it is widely used in African American Vernacular English and Southern English. If someone uses it in a more formal context, it is likely that they want to convey a casual or insouciant attitude. However, any native English speaker knows what it means, so there should be no issue in terms of communication. On the other hand you might justify not using it on the grounds that it might give non-native speakers some trouble.