You are misunderstanding what constitutes a wash sale. In your example, the wash sale rules do not apply (as long as you don't buy the stock again for 30 days after the sale).
Let's say that you bought your 100 shares of XYZ for $50 each. At some point in the future, the price drops to $40. You think that the price will bounce back and you want to continue to hold, but you would like to deduct the loss on your taxes. Therefore, you decide that you will sell XYZ at $40 (for a total loss of $1000), but you repurchase the stock again (also at $40). The transaction cost you nothing (as you sold and bought at the same price), and you still own 100 shares of XYZ, but now you think you have a $1000 loss to deduct. However, the wash sale rule exists to prohibit the deduction under this circumstance.
In your example, at the end of the story the investor no longer owns the stock. Therefore, as long as 30 days go by without him owning the stock, the wash sale rules do not apply. The investor legitimately lost $1000, and can take the deduction. After 30 days go by, the investor is free to buy again, if he wishes, and start a brand new cost basis.
Here is how to correctly parse the tax code you cited:
26 U.S. Code § 1091 - Loss from wash sales of stock or securities
(a) Disallowance of loss deduction
In the case of any loss claimed to have been sustained from any sale or other disposition of shares of stock or securities where it appears that, within a period beginning 30 days before the date of such sale or disposition and ending 30 days after such date, the taxpayer has acquired (by purchase or by an exchange on which the entire amount of gain or loss was recognized by law), or has entered into a contract or option so to acquire, substantially identical stock or securities, then no deduction shall be allowed under section 165 unless the taxpayer is a dealer in stock or securities and the loss is sustained in a transaction made in the ordinary course of such business. For purposes of this section, the term “stock or securities” shall, except as provided in regulations, include contracts or options to acquire or sell stock or securities.
The 100 shares that you sold at a loss were the 100 shares that you purchased 2 weeks earlier. That purchase transaction doesn't count. You legitimately have a "loss claimed to have been sustained from any sale or other dispostion of shares of stock." The next part of the sentence says, "where it appears that, within a period..., the taxpayer has acquired... substantially identical stock or securities, then no deduction shall be allowed." This has not happened. You did not dispose of some shares, and then within the period purchase additional identical shares. You had no shares to start, you bought them, you sold them at a loss, and ended with no shares. This is not a wash sale under these rules. The shares that you purchased 2 weeks earlier was not a purchase of substantially identical shares. It was the initial purchase of the shares that you sold.
The tax code is very hard to read, and can be misleading if you aren't used to looking at it. The IRS issues publications that are intended to be more clear and easier to parse. IRS Publication 550 has this to say about wash sales:
A wash sale occurs when you sell or trade stock or securities at a loss and within 30 days before or after the sale you:
Buy substantially identical stock or securities,
Acquire substantially identical stock or securities in a fully taxable trade,
Acquire a contract or option to buy substantially identical stock or securities, or
Acquire substantially identical stock for your individual retirement account (IRA) or Roth IRA.
It says that in order to have a wash sale, you must sell the stock at a loss and you must acquire substantially identical stock within the window. In your example, the second part has not occurred. The investor sold the stock at a loss, but he did not acquire substantially identical stock. The first purchase was the purchase of the stock he sold for a loss.
The publication goes on to list 4 examples, each of which shows a wash sale. In every example, the investor is shown buying stock at some point in the past that is not in the window. It is the purchase of additional identical shares before or after the sale of the old shares that makes it a wash sale.
Here is the important thing to note about the wash sale rule that you may be missing. Yes, the wash sale rule, when triggered, prevents you from taking a capital loss deduction. However, it does not prevent you from taking the loss forever; instead, you add the loss to the cost basis of the shares you still have.
For example, let's say that I buy 100 shares of stock for $50. A year later, I sell those 100 shares for $40, and just before I did that, I purchased 100 shares at $45. Wash sale rules prevent me from deducting the loss now, but I can take that $10 per share loss and add it to the cost basis of the shares I still have. The cost basis of the 100 shares I have is now $55, and when I sell them in the future, this reduces the capital gain I will have (or increases the capital loss).
In your example, there are no remaining shares with which to add on to the cost basis. The wash sale rule doesn't even make sense in this scenario, because there is nothing remaining on which to tack on the loss.