stop writing links each `scrape_links()` loop

Write links only on return from `scrape_links()` to `main()`, at end of
main loop.

Also, modularize `get_random_link()` and do it at end of main loop.