This is absolutely normal. A significant amount of what everyone does is done wrong the first time, no matter how careful you are. "Just get it right" is not sustainable, no matter what effort you put out. I think that the usual estimate is about 10%. As in about one line in 10 initially contains some typo, syntax error, thinko, etc.
The key is to set things up such that these mistakes are caught and fixed before they hurt anyone. If you want to learn a lot about how to do this, I highly recommend reading Code Complete. Yes, I'm aware that it is a tome. However it is a worthwhile tome that is worth reading and re-reading until you've incorporated it as practice.
The key is to set things up such that these mistakes are caught and fixed before they hurt anyone. If you want to learn a lot about how to do this, I highly recommend reading Code Complete. Yes, I'm aware that it is a tome. However it is a worthwhile tome that is worth reading and re-reading until you've incorporated it as practice.