After a promising start to morning trading, the major stock indexes turned sharply negative Friday with the S&P 500 tumbling into bear market territory and the Dow Jones Industrial Average setting up for the longest streak of weekly losses since the Great Depression.

And then stocks turned around again, to end the day mostly flat.

The Dow ended the day nearly flat, which brings its weekly decline to 2.77 percent. This was eighth consecutive weekly loss for the index. That is the longest losing streak since 1932.

The S&P 500 ended the day up 0.01 percent, which is more or less flat. Even with the afternoon reprieve, this is the seventh weekly loss for the broad index, the most since 2001. For  breif time today, the S&P was down 20 percent from recent highs, the official marker for a bear market. But the afternoon rally pulled it back into positive territory and above the bear-line.

Five of the eleven sectors of the S&P were up. The worst performing sector was consumer discretionary stocks, down 3.73 percent.

The Nasdaq Composite fell 0.3 percent.

Bond yields, which move in the opposite direction of bond prices, were down, indicating that investors were paying more for the safety of U.S. government securities. The yield on the 10-year Treasury bond fell 0.076 points to 2.788 percent.

Investors are spooked by the negative impact inflation has had on the earnings of major retailers like Walmart and Target and the prospect that the Fed’s interest rate hikes could topple the economy into a recession. The threat of stagflation—low growth with high inflation—is looming larger in the minds of many investors.