Your first mistake is going to the car dealer without an offer in writing. The trick is to email several dealerships and pit them against each other, so you're only walking in the door when you have the best price available in writing.
Fortunately, my experience shows there are honest dealers that do not renege on their promises and respect both themselves and their customer. Even in this business, notorious for some bad apples, there are also decent ones.