Finding a bug

A bug is found by comparing what you think each line did with what it did, by printing or tracing the values at the point where they first differ, then changing one thing and running again.

From Introduction to Computer Science.