IIRC, Twitter was operating at a loss, prior to the closing of Elon's purchase.
See Q2 2022 Results here, net loss was $270 million -https://s22.q4cdn.com/826641620/files/doc_financials/2022/q2...
It's still an open question whether Twitter will succeed with Elon, but it definitely wasn't a healthy company prior to the purchase.