LM358 as a comparator output problem
Not every op amp is perfect, nor is an op amp a good substitute for a comparitor. Please consider replacing it with an actual comparitor. As for why you should, that op amp must be pulled down with a 2KOhm resistor or higher in order to meet TTL logic specs (Vcc-1.5 = 3.5V in this case). It's in the datasheet. The Diode is there to prevent the op amp from sinking current and even out the H->L and L->H transition time.

As for why your output is not working. I'd have to see a diagram. From what you describe it should be working.