For a railway to be saved as a .rly file, all locations (connected stations and 'blue' non-station locations) must be named. This is done using the "Set or Change Station Names" by selecting the location and entering a name.
Naming a station using the "Set or Change Station Names" tool.