The Royal Westphalian Railway was initially established only to fill the 32 km-long gap between Hamm and Lippstadt, connecting the Münster–Hamm line of the Munster–Hamm Railway Company opened in 1848 with the line being constructed at the same time by the Cologne-Minden-Thuringian Connection Railway Company. The latter company, however, went bankrupt in 1848 and further construction and the line's later operations were taken over by the Prussian government. The cause of the bankruptcy of the KMTVEG was the difficulty of building a 600-metre-long tunnel at Willebadessen under the main ridge of the Eggegebirge range. The tunnel, which was never completed, was designed to avoid bridging the valley at Altenbeken. The remains of the site are still visible after more than 150 years; these ruins are known as the Old Railway. The main line of the Royal Westphalian Railway ran from Hamm via Soest, Lippstadt, Paderborn and Altenbeken to Warburg. It was opened on 4 October 1850 to Paderborn and on 21 June 1853 to Warburg. The line was first railway in western Germany to cross mountainous country. The Altenbeken Viaduct was a significant achievement of the early German railways. After the company took over the Münster–Hamm Railway Company in 1855, it extended the Münster–Hamm line to Rheine in 1856 and to German ports on the North Sea. Together with the Royal Hanoverian State Railways, it built a connection from Rheine to the German ports on the North Sea. This was a very important connection for Prussia because of the high tariffs charged by the Dutch Rhine ports. The Kingdom of Hanover was annexed by Prussia after the Austro-Prussian War of 1866 and two years later this line became part of the Westphalian Railway. Together with the Rhenish Railway Company, it built and operated a generally straight line, opened in 1876, from Welver station, via Unna-Königsborn to Dortmund South station. The line was extended to the west in 1879 as the Westphalian Emscher Valley Railway via Dorstfeld, Bodelschwingh, Mengede, Herne, Gelsenkirchen, Horst to Osterfeld WfE station. Operations on this line proved to be uneconomic and sections of it were soon closed, following the nationalisation of its main competitors.