While I think there is truth to your point, it's also true that some loopholes are the result of unintended consequences rather than conscious creation. In these instances, there will still be companies lobbying to keep these loopholes open, but the government can still fail at closing loopholes even when they are explicitly trying to close them.
I think that that for every "loophole", separating the legitimate and illegitimate users (however you wish to define those) objectively is next to impossible.