Built in 1868, the New York and Oswego Midland Railroad traveled from New York City to Lake Ontario via Pennsylvania and connected many small towns that were not served by any previous lines. The cost of building the rail line through hilly terrain bankrupted the Midland Railroad, and the railroad reorganized as the New York, Ontario and Western Railway in 1880. The mainline of the railroad passed through Hamilton, New York, contributing to the economic development of the region by transporting coal, hops, milk, and passengers. The New York, Ontario and Western Railway entered bankruptsy in 1937, due in part to declining sales of coal, which constituted a significant portion of the railroad's freight business. The railroad closed in 1957 and the rail lines were subsequently abandoned.
In 1955, a thrown switch caused a derailment in Hamilton, where the locomotive was thrown 150 feet through the air and became known as the "Flying Diesel Corps." The wreck resulted in spilled candy bars from a local Nestle plant in Fulton, New York--much to the delight of local children.