Just one thought. Isn't it better to do it with some kind of DB like MySql, or SQLite, INSERTing new urls and UPDATEing the count if there is one?