How to save list of open Safari Tabs in a text file?
The following example AppleScript code will write the URL of every tab of every window of Safari to a file named MyURLs.txt on your Desktop:

set myURLs to {}
tell application "Safari" to set myURLs to the URL of every tab of every window
set text item delimiters to linefeed
set myURLs to myURLs as text
set text item delimiters to {}
if not myURLs is equal to "" then
    do shell script "echo " &amp; myURLs's quoted form &amp; "&gt; $HOME/Desktop/MyURLs.txt"
end if




To open the URLs in, e.g., MyURLs.txt you can use, e.g.,:

set myURLs to {}
try
    set myURLs to paragraphs of (do shell script "cat $HOME/Desktop/MyURLs.txt")
end try
if not myURLs is equal to {} then
    repeat with thisURL in myURLs
        open location thisURL
    end repeat
end if



The example AppleScript code above assumes Safari is your default web browser.




Note: The example AppleScript code is just that and does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.