The example below throws an InvalidOperationException, \"Collection was modified; enumeration operation may not execute.\" when executing the code.
var urls
Consider using a Queue with while loop (while q.Count > 0, url = q.Dequeue()) instead of iteration.