In addition to being perhaps the most successful long-term investor in history, Warren Buffett has penned a host of memorable aphorisms in the course of writing dozens of annual Berkshire Hathaway (NYSE:BRK.A) (NYSE:BRK.B) shareholder letters.

One of his most famous sayings dates back to the 1986 shareholder letter, when Buffett wrote: "Our goal is more modest: we simply attempt to be fearful when others are greedy and to be greedy only when others are fearful." He reiterated the point in another shareholder letter nearly two decades later, saying that if investors feel compelled to try to time the market, "they should try to be fearful when others are greedy and greedy only when others are fearful."

Many value investors probably thought they were following Buffett's advice by buying airline stocks hand over fist as they plunged between February and April. On average, shares of the four largest U.S. airlines -- American Airlines (NASDAQ:AAL), Delta Air Lines (NYSE:DAL), Southwest Airlines (NYSE:LUV), and United Airlines (NYSE:UAL) -- have lost about two-thirds of their value since mid-February.

AAL Chart

Airline COVID-19 Stock Performance, data by YCharts.

If so, it must have been quite a shock to learn last Saturday that Buffett sold all of Berkshire Hathaway's substantial airline investments at a loss in recent months. (Moreover, he didn't make any major new stock acquisitions despite the market's big drop in March.) What gives?

The advice is about the stock market

The first thing to note about Buffett's sage advice regarding greed and fear is that he was talking about the stock market: not individual stocks. In his 1986 letter, Buffett said that he bought bonds with Berkshire's insurance float rather than stocks -- despite thinking the bonds were mediocre investments -- because stocks had been driven to irrationally high levels. Buffett had to do something with the money, and bonds served as a relatively safe placeholder while other investors were being greedy with stocks.

Buffett was even clearer in his 2004 letter. Just one paragraph before the quotation about greed and fear, Buffett opined that most investors' best strategy would be to buy and hold an index fund. He then advised investors that if they could not bring themselves to just buy and hold, they should try to be greedy when others were fearful. Presumably, he was still talking about buying an index fund -- not betting on individual stocks.

Buying an index fund when the market declines significantly is a strategy with good odds. There's some level of safety in being diversified across the whole economy. (It's still not foolproof: The market dropped 12% in 1929 and another 28% in 1930. That might have seemed like a good buying opportunity, but the S&P 500 then plunged 47% in 1931 and fell another 15% in 1932!) By contrast, shares of individual companies can plummet because their earnings prospects have permanently changed for the worse. At the limit, this can result in a company going bankrupt and the stock being canceled.

What goes down does not always go back up

Warren Buffett is keenly aware that this is true of the airline industry. He spent the better part of two decades warning investors against investing in airlines, noting that they had repeatedly destroyed investors' capital over the course of a century. (Of course, he changed his mind several years ago, building up big stakes in American Airlines, Delta Air Lines, Southwest Airlines, and United Airlines.)

An American Airlines plane in flight, with mountains in the background

Warren Buffett sold all of Berkshire Hathaway's airline stocks in recent months. Image source: American Airlines.

Berkshire Hathaway's investment in American Airlines stock was always somewhat strange given the airline's high debt and below-average margins. Yet the other three airlines had solid track records for free cash flow production prior to Berkshire getting involved. Given the structural changes to the U.S. airline industry (mainly consolidation), Buffett wasn't totally irrational to think that airlines had matured into high-quality businesses.

But as Buffett wrote in Berkshire Hathaway's 2001 annual letter, "... [Y]ou only find out who is swimming naked when the tide goes out." The tide has gone out in a big way for airlines in 2020. Demand has virtually evaporated. The result was that even industry stalwarts like Southwest and Delta -- which have earned consistently high margins in recent years -- lost money last quarter and are bracing for even bigger losses ahead. American and (to a lesser extent) United have had more mixed track records over the past few years and are even worse off now.

Buffett's recent venture into and out of airline stocks can best be explained in two sentences from Berkshire Hathaway's 1987 shareholder letter: "Our goal is to find an outstanding business at a sensible price, not a mediocre business at a bargain price. ... Of course, Charlie and I may misread the fundamental economics of a business." Airlines appeared to be high-quality businesses for most of the past few years. Today, they seem far more speculative in nature, making it natural for Buffett to admit his mistake and sell Berkshire's airline stocks.

Channel greed wisely

As I wrote last weekend, I think Warren Buffett is unduly pessimistic about the airline industry's prospects. As a result, I decided to double down on shares of Delta Air Lines and Southwest Airlines last month. Both airlines face severe business headwinds right now, but I believe investors (including Buffett) are underestimating their ability to adapt if demand remains virtually nonexistent for an extended period.

However, I have learned from Buffett that being greedy when the market is fearful does not mean buying indiscriminately. The money I used to increase my investment in Southwest Airlines stock came from selling American Airlines stock at a loss -- even though American's share price has fallen more than that of Southwest. While I had been optimistic about American's turnaround potential, it will have trouble navigating the current crisis successfully due to its massive debt load.

More broadly speaking, while the market sold off sharply in March, by the second week of April it was back near last summer's levels. There may still be a few bargains in the stock market, but investors must use extreme caution. Most of the stocks that are still nursing big losses probably deserved a big drubbing.