Now let me start by saying I in no way think anyone should mess around on an active railroad but I remember an old Popular Mechanics (I think) article where a guy built a bicycle for riding on the abandoned railroad spurs around his area. He pretty much put rail followers on the bike and an outrigger with a small roller for the other rail.
Could you imagine a setup like that with a motor! Unfortunately all the abandoned lines around here were taken up when the price of steel shot up years ago and were made into walking trails.
Cool, there seems to be a lot of people still doing it.
YouTube - Rail Rider rail bike