"Instead, this 'loss out of nowhere' is hidden in the detail that economists lose by treating infinitesimally small quantities as zeros. If perfectly competitive firms were to produce where marginal cost equals price, then they would be producing part of their output past the point at which marginal revenue equals marginal cost. They would therefore make a loss on these additional units of output.
As I argued above, the demand curve for a single firm cannot be horizontal-it must slope downwards, because if it doesn't, then the market demand curve has to be horizontal. Therefore, marginal revenue will be less than price for the individual firm. However, by arguing that an infinitesimal segment of the market demand is effectively horizontal, economists have treated this loss as zero. Summing zero losses over all firms means zero losses in the aggregate. But this is not consistent with their vision of the output and price levels of the perfectly competitive industry.
The higher level of output must mean losses are incurred by the industry, relative to the profit-maximizing level chosen by monopoly. Losses at the market level must mean losses at the individual firm level- yet these are presumed to be zero by economic analysis, because it erroneously assumes that the perfectly competitive firm faces a horizontal demand curve."
- —Steve Keen, Debunking Economics, 2011