How to make the LM339 IC source current on its output pins instead of sinking current?
modified circuit to use PNP transistor



If open circuit condition is making issue (when the output is not sinking), use the 4.7k pull up as in your circuit

updated the circuit based on the comment by @Paul Elliott