My wife had a child with another man while we were legally married, how to file?

My wife and I were legally married all of 2017 with not legal separation. She got pregnant in 2016 with another mans child. She lived with me until October of 2017 and had the baby in August. 2017. We are still planning on filing married jointly for tax reasons but we are now legally separated as of 1/12/18. We currently have 2 kids we always claim as dependents and she is wanted to claim the newest child when we file for 2017. Since the child is legitimately hers, is that an issue. There aren’t any custody arrangements with the father of the child but her and the child stayed with him from oct until December. He or his parents pay for childcare so we would not be taking advantage of the childcare credit for that child. Although. I paid for the child’s registration fee which I have not been reimbursed by the father so technically I did pay some childcare. Also. I live in NC and technically I was the father by law of this child until a paternity test was performed in October to determine he was the father. Can we claim her on our taxes as a dependent since my wife carried her, used her insurance policy for the birth and paid her medical bills? Is it still beneficial to claim married jointly or should we consider married separately?