A lot of code editors (Xcode doesn't by default, but you can easily configure it to) have a keyboard shortcut for duplicating the current line. I have plenty of times accidentally made changes at the wrong place in a file because I was mistaken about where the cursor was. The lesson is to always make sure to look at your diffs before you commit your changes.
Google / Chrome does this, and so should everyone else, even more so if they're dealing with security.