DURING the crisis of 2008-09, Warren Buffett made two big bets in the midst of the panic. He bought a slug of preferred stock in Goldman Sachs. And he took over BNSF, a huge railway. Goldman’s 32,500 bankers and BSNF’s 32,000 miles of tracks, stretching from the Pacific to Texas, had nothing in common, except that it was impossible to imagine American capitalism without them. “It’s an all-in wager on the economic future of the United States,” declared Mr Buffett when he bought the railway company, which, naturally, was advised by bankers working for a certain “vampire squid”.

How right Mr Buffett was. The last decade has been a golden one for shipping goods around the world’s biggest economy (each citizen’s consumption of goods and power requires the movement of 36 tonnes of freight a year). American railways have been a rare example of capitalism working well, with a virtuous cycle of demand, giant profits and vast investment in rolling stock and tracks.

Foreigners who snipe at America’s late-Brezhnev-era airports, smelly subways and rutted roads should, as the Proclaimers sang, take a look up the rail tracks from Miami to Canada. Fixed assets at North America’s six biggest freight-rail firms rose by 58% between 2004 and 2014, to $250 billion (see chart). Private firms have been spending almost as much each year on modernising American locomotives and tracks as the federal government has on roads. The infrastructure splurge has helped the environment, too, since trains are about four times as fuel-efficient as lorries. America’s freight railways are more efficient and far busier than their counterparts in Europe.

But now this privately fuelled locomotive has been derailed. In the last quarter of 2015 the combined earnings of the big American and Canadian freight-rail firms fell by a fifth, compared with a year earlier, mainly because of the commodity-price crash. The industry has tried to shrug this off as a temporary blip. But if the downturn persists, the investment extravaganza will be over. Tougher times also raise the spectre of rail mergers, a phenomenon that has vexed America ever since the first transcontinental line was hammered together in the Utah desert in 1869. Dealmaking is already in the air, with Canadian Pacific (CP) pursuing a reluctant Norfolk Southern. This week CP said it would propose a shareholder resolution calling on Norfolk’s board to negotiate a merger. The deal is backed by Bill Ackman, an activist investor. It has thrilled Wall Street, peeved rival firms and put regulators on red alert. Before asking how the industry’s fortunes could go wrong, however, how did it all go right? Since being deregulated in 1980, American railways have gradually got their acts together. Plenty of tailwinds are behind them. Freight volumes typically grow with GDP. And rail, with a market share of about 40%, should take business from road haulage, now with over 50% of traffic, which faces tightening emissions rules and a struggle to recruit drivers. Greasing the tracks in the past decade was the commodity bubble. Newly drilled shale oil needed to be shipped from remote basins, and coal moved to power stations and ports—American coal exports doubled between 2005 and 2011, thanks to demand from East Asia and Europe. Intermodal transport (containers moved from ship to rail to lorry) rose rapidly, too, and now accounts for a fifth of sales.

Rail managers discovered their inner rottweilers. Hunter Harrison, who runs CP (and before that was at CN, Canadian National), is eulogised by investors for his ruthless scheduling—he is said to monitor individual trains as they chug across the continent. Most important of all, after declining steadily since the 1980s, freight prices were jacked up stealthily, rising by 42% in real terms since 2004.

Railroads could be accused of gouging their customers: pre-tax return on capital for the big six firms rose from 10% in 2004 to 19% in 2014. But that misses the bigger point. For every dollar of gross cashflow in 2014, 67 cents was reinvested. The industry’s appetite for capital spending is all but unique in America, where most firms spend bumper profits on share buy-backs to boost their stock price. Rail firms’ resistance to this corporate crack cocaine is hard to explain, but may reflect the lingering presence in their boardrooms of gnarled railmen with a love of horn blocks and glad-hand connectors, rather than earnings-per-share enhancement.

What is clear is that the investment spree is now under threat from slumping profits. The shale industry is reeling. Coal volumes have fallen, as domestic power generators switch to dirt-cheap natural gas and the strong dollar hurts coal exports. The industry has solid enough balance-sheets to weather a storm, with net debt of 1.8 times gross operating profit. But an age of austerity beckons. Capital investment fell by 15% in the last quarter of 2015 compared with a year earlier. In 2016 it could drop by 20%.

The industry’s unspoken plan is probably to keep raising prices while investing less and returning more cash to shareholders to keep them happy. This approach is likely to enrage everyone else. Customers such as carmakers, energy utilities and shipping firms will complain of being squeezed. Regulators will fret that the pace of modernisation has slowed. Despite a decade of huge investments there are still pressing congestion problems, particularly in Chicago, a bottleneck through which much of America’s freight is rammed.

So how can the industry continue to satisfy both investors and society if demand and profits are lower and the need for capital spending is just as high? Perhaps by turning the big six railways into four, or even two. How big the rewards would be from mergers is fiercely contested. Mr Harrison says he could cut $1.8 billion a year from Norfolk’s costs (equivalent to a quarter of the total), although most of those gains would come from running it better, not from synergies through bolting it onto CP. Norfolk says he is exaggerating.

Take your hands off my train set

Train mergers have been an explosive subject for over a century, with a dread of isolation or exploitation at the hands of railway robber-barons lodged deep in America’s subconscious. The last round of deals was permitted in the 1990s, when the number of big train firms fell by half. The antitrust apparatus today is clunky. The federal Surface Transportation Board (STB) has had broad powers to block rail mergers on public-interest grounds since 2001. But it struggles to articulate a logic for assessing what it thinks makes a system better—does it want choice, modest returns on capital, lots of operators, lots of route combinations, or low prices?

The industry already consists of three geographical duopolies—the West (where BNSF and Union Pacific dominate), the east (Norfolk and CSX) and Canada and its links to the United States’ industrial north (CP and CN). It is not obvious why linking two non-overlapping rail networks would make any area less competitive.

But even saying that is taboo, and a giant head of steam is building up across the country against the CP-Norfolk deal. The Alabama State Port Authority is sceptical, Ohio’s soyabean farmers are livid, western Kentucky’s coal miners are perturbed, and the Brotherhood of Locomotive Engineers and Trainmen foresees a “death spiral”. Most are worried about services and jobs being slashed. Both Union Pacific and CSX have said they oppose a deal. On February 4th nine members of Congress from Indiana asked the STB to be vigilant. The regulator itself is likely to be worried about the short-term disruption dealmaking could create. Consolidation in the 1990s caused chaotic delays.

So Mr Harrison’s proposed deal looks likely to struggle. Yet the near-universal hostility to consolidation reflects a complacency born of the golden years. Now that cash is no longer raining down it will be harder to satisfy investors, customers and the long-term national interest all at once. Perhaps a rationalised rail system will ultimately be seen as the best solution for congestion. It may, however, take someone with Mr Buffett’s legendary patience to witness it.