From Beverly to Rockport, the 1888 USGS map names this as the Boston & Main RR. An 1881 map of Cape Ann calls this line the Eastern RR; stops at Pride's Crossing, Beverly Farms, W Manchester, Manchester By the Sea, Magnolia, W Gloucester, Gloucester, and Rockport.
It has been suggested by Rick Nowell,Archives Chairman Boston & Maine Railroad Historical Society:
Portland, Me. to Portsmouth, N.H. via Portland, Saco & Portsmouth RR. At the time of the trip, 1869, PS&P was under lease jointly to the Boston and Maine and Eastern RRs, so I think it was still operating as PS&P. Later PS&P was leased to Eastern and operated under the latter name.
Portsmouth, N.H.. to Beverly, Mass. via Eastern RR. The trip from Portland to Beverly was likely made without change of train. Change trains at Beverly.
Beverly, Mass. to Rockport, Mass. via Eastern RR.
The no-name line from Lawrence to Gloucester is a hypothetical line from the 1870 kml collection. There is no trace of it on any of the USGS maps.