To encourage investment, the tax code provides an incentive to soften the blow of a loss