delete_dups modified

now uses pythonic "with"
also now closes opened files