Using an Op-amp as comparator
You'll need an opamp that can swing up to vcc. Old things like the 358 cannot. It's an inherent limitation of the design.

Look for rail to rail op amps, or better yet, use a proper comparator!