Check if host is up before scanning

Moved the code in a main() function to simplify an exit of the script if something goes wrong.