If you’re looking for sustainable companies to invest in, the railroads are a great place to start. After all, it’s simply impossible to build another track network. So, we can practically be certain that Canadian National Railway Company (TSX:CNR)(NYSE:CNI) and Canadian Pacific Railway Limited (TSX:CP)(NYSE:CP) will still be going strong 50 years from now.

That being the case, these companies aren’t necessarily free and clear. Below are three long-term threat to the rails.

1. The emergence of trucking

If you need to ship a large volume of goods over a long distance, then rail will always be far cheaper than trucks. But trucking has more flexibility than the rails, making it ideal for shorter routes and smaller shipments. It’s on those in-between routes where rail and trucks compete fiercely.

And trucks have become more competitive recently thanks to lower diesel prices. Of course this reduces costs for the rails too, but not as much. Longer term, we could even start seeing driverless trucks, making them even more competitive with the rails.

2. The emergence of pipelines

The crude-by-rail business has absolutely taken off over the past few years, driven by increased production in areas with limited pipeline capacity. But moving crude oil in rail cars is expensive, environmentally unfriendly, and dangerous. Over time, you should expect more pipelines to be built. And not all of them will run into environmental opposition like Keystone XL did.

Even worse, the decline in oil prices is hurting the economics of crude by rail, especially in Alberta’s energy patch. We’ll likely be seeing more downward revisions for this business.

3. The decline of commodities

Commodities account for a big proportion of the rail companies’ carloads. And a bunch of commodities are facing major headwinds.

Chief among these headwinds is China’s slowing growth, which is hurting demand for metals and minerals. The coal industry is also suffering with no end in sight. Meanwhile, the forest products industry is highly cyclical.

What should you do?

First of all, let’s make one thing very clear: none of these three issues will destroy the rails. But they should not be ignored, and could easily take a bite out of revenues and profits.

Making matters worse, both these companies are quite expensive by most standards. CN trades at roughly 20 times earnings, while CP trades at 22 times. And when looking at free cash flow instead of earnings, the multiple is even higher.

So, if you’re looking for a stock to help you sleep at night, you should start with the rails. Otherwise, you can find more upside in other industries. The free report below is a great place to start.

This rock-solid stock has more upside than the rails

Our analysts have identified this company as one TOP stock for 2015 and beyond. And you can download the name, ticker symbol, and price guidance absolutely FREE.

Simply click here to receive your Special FREE Report, "1 Top Stock for 2015--and Beyond."

NEW! This Stock Could Be Like Buying Amazon In 1997

For only the 5th time in over 14 years, Motley Fool co-founder David Gardner just issued a Buy Recommendation on this recent Canadian IPO.

Stock Advisor Canada’s Chief Investment Adviser, Iain Butler, also recommended this company back in March – and it’s already up a whopping 57%!

Enter your email address below to claim your copy of this brand new report, “Breakthrough IPO Receives Rare Endorsement.”

Fool contributor Benjamin Sinclair has no position in any stocks mentioned. David Gardner owns shares of Canadian National Railway. The Motley Fool owns shares of Canadian National Railway. Canadian National Railway is a recommendation of Stock Advisor Canada.