Great Discussion Topic.
Both scripts are useless as SQL. This is a great example of CURSOR, FLOW Control, PRINT and general SQL misuse.
Never use an object until you understand the use case for the object.
Would you use a single string that is a comma separated list of strings instead of an array?
The largest problem with CURSOR use is lazy development by those that want SQL to be a language like VB or C .
Line value based languages built to examine distinct singular objects and values.
These are not languages to be used on Sets of objects with Sets of Values like SQL.
IMHO - Both the while and the cursor scripts you have here are not really SQL.
They are something else pretending to be SQL by wearing an SQL Suit.
I have never seen the Print command in production SQL code.
I have seen it in way to many Programing example applications.
SQL looks like this -
SELECT ' Linked Server DETAILS- ' + CONVERT(Varchar(max), a.name) FROM sys.servers a WHERE is_linked ='1'
SQL returns data in a Record Set of column and rows. Not the output of a print command to the Message Object.
ROW or Value based DML is not for logical flow control.
DML will always work with SETS of data, even when inspecting it at the ROW level.
If you are returning data to any output ROW by ROW, that is not SQL that is a VB script structure or maybe error handling.