Adding a forever loop with a sleep, and reducing duplicate code

This way I can use it more like real ping, although it doesn't sleep between each A/AAAA record.