Careful here, ktfo. Your W didnt just decide one day to up and have an affair. You described some problems in your marriage. This is not ALL her. In general, Id guess the breakdown in your marriage is somewhere close to 50-50. So, yes, you did some things wrong.
BUT that doesnt mean you have to KEEP doing things wrong. Its time to reflect back and think about what you did to contaminate your marriage. And figure out how to fix that in yourself going forward.