Van Jacobson's original 1988 traceroute exploited exactly this TTL-expiry behavior, and the traceroute/mtr binaries on every Linux box still increment TTL and read ICMP Time Exceeded messages the way you do here. Network engineers use this technique daily to localize where in a path latency or packet loss is being introduced.