The lines are from the famous poem “Tam o’ Shanter” written by Robert Burns in 1790. It is one of his finest poems and his own favourite. Vivid and inventive, it turned a little-known local tale of witches into an epic narrative.

Tam o’ Shanter's wife Kate is described by Burns in the poem as a “sulky sullen dame” sitting at home, “Gathering her brows like gathering storm, nursing her wrath to keep it warm”. Tam regularly stays out at all hours, drinking with cronies, until one night poor Tam has to flee for his life from witches, gathered to dance to the devil's bagpipes, at the old haunted Kirk (church) in Alloway (in Ayrshire, Scotland).

On his way home past the Kirk, Tam sees warlocks and witches in a frenzied, bawdy dance. He is drunk and drawn to the scene of debauchery. One shapely, supple and scantily-clad young witch takes his attention. In excitement he roars out "Weel done, Cutty-sark!" – “cutty sark” being the old local name for a short undergarment or petticoat. Then “out the hellish legion sallied” to give chase to Tam and his horse Maggie (referred to also as Meg). They only just make it to safety with Maggie suffering the loss of her tail to the witches in pursuit. Tam made it back home to Kate, waiting no doubt to serve up some hot tongue and cold shoulder for his supper.

Robert (Rabbie) Burns (25 January 1759 – 21 July 1796), was a Scottish poet and lyricist. He is regarded as the national poet of Scotland and is celebrated internationally.

More Info: en.wikipedia.org