What would it take to have a perfectly working program?
A program that never fails and does exactly what you want every single time would be amazing but not real.
This is impossible because perfect software doesn't exist and the faster you come to conclusion with that the faster you will stop wasting your energy and time.
Software will never be perfect; this is why there continue to be upgrades and bug fixes. Everything improves over time and it does so faster when more users see it and have the opportunity to provide help.
Now we know this we can code better by being more cautious, defensive, and anticipate the unexpected. The help of others will give your code more views to spot mistakes or critical logical errors that you may have overseen.
Overall, you may not have a perfect program but you can take the steps to ensure that it is close to flawless leaving room for upgrades and enhancements.