Idea for bad print detection to save hotend

I have an idea to save hotends from getting destroyed automatically. If there was an led transmitter and a light receiver on either side of the nozzle, It could detect when filament gets pushed up over the tip of the nozzle then send a stop signal to the machine. Just a thought. Thanks for listening.