Three railroads developed in Alexandria during the mid-19th century, after heavy local investment in the Alexandria Canal, which opened in 1843 and by 1850 gave the city access to the Cumberland coalfields through the Chesapeake & Ohio Canal. Alexandrians then turned to railroads to link the city with Shenandoah Valley farmland, though the Baltimore & Ohio Railroad had already diverted much trade to rival Baltimore by reaching Harpers Ferry in the mid-1830s and Cumberland by 1842. Even so, Alexandria's railroads became important to the city's prosperity before the Civil War by carrying passengers, mail, and freight to and from western Virginia. The Alexandria and Harpers Ferry Railroad, founded in 1847, was later reorganized as the Alexandria, Loudoun and Hampshire Railroad and connected Alexandria with Leesburg. The Orange and Alexandria line, incorporated in 1848, extended west to Warrenton and Gordonsville and by 1859 linked with the Virginia & Tennessee Railroad at Lynchburg. The Manassas Gap Railroad was chartered to connect Strasburg and Harrisonburg in the Shenandoah Valley with the Orange & Alexandria Railroad near Manassas Junction. Formed in 1854, the Alexandria and Washington Railroad linked Alexandria with Washington but was barred from interconnecting with the city's other railroads; it carried passengers and freight to the Virginia side of Long Bridge (14th Street), where traffic crossed the Potomac River into Washington by foot, stage, or wagon. During the Civil War, all of these lines were consolidated as Alexandria became a vital distribution center for Union soldiers and supplies, and by 1862 the Union Army had interconnected the railroads and laid tracks across Long Bridge to join the northern stretches of the Baltimore & Ohio Railroad. The Orange and Alexandria roundhouse and machinery shops became headquarters of the Union Military Railroads. After the war, the railroads returned to civilian ownership and helped revive Alexandria's economy, though the city never industrialized; tracks were extended and lines merged to connect Alexandria with Richmond. In the 1870s, cattle and agricultural produce, including fresh fruit and perishable dairy products, moved daily from the Shenandoah Valley to markets in Alexandria and Washington. In the late 19th century, Alexandria's lines became entangled in the rivalry between the Pennsylvania Railroad and the Baltimore & Ohio Railroad. The Alexandria and Washington Railroad was acquired by the Pennsylvania Railroad and eventually became part of the Richmond-Washington line, which opened Potomac Yard in 1906 as a major freight interchange later managed by the Richmond, Fredericksburg & Potomac Railroad. The original Manassas Gap and Orange & Alexandria Railroads first came under Baltimore & Ohio control and later were incorporated into J.P. Morgan's Southern Railroad System. Alexandria's first railroad, the Alexandria, Loudoun and Hampshire Railroad, became part of the Washington & Old Dominion Railway and finally ceased operation in 1968.