Help with script unexpectedly stopping/erroring out while iterating through a list

Working on a project to download a list of files from an FTP server and when running it dies right before downloading the last file.

#Log beginning of modification
#If the unmetered address list file size is larger than 0, begin
#Remove all previous entries
#Put the content of the txt file into the variable $content
#Get the total length of $content

:log info "Starting Hotspot Download"
:if ( [/file get [/file find name=file-list-hotspot.txt] size] > 0 ) do={
  /tool fetch mode=ftp user=**USER** password="**PASSWORD**" address=update.**SERVER**.com src-path=~/filelist/hotspot.txt dst-path=file-list-hotspot.txt port=21
  :local content [/file get [/file find name=file-list-hotspot.txt] contents] ;
  :local contentLen [ :len $content ] ;

#Set lineEnd to 0
#Set line to null
#Set lastEnd to 0

:local lineEnd 0
:local line ""
:local lastEnd 0  

#Beginning of do/while loop
#Set lineEnd to the first point in the line there's a newline char
#Set line to be whatever is between lastEnd and lineEnd
#Set lastEnd to be lineEnd + 1 (ready for new line)

  :do {
    :set lineEnd [:find $content "\n" $lastEnd ] ;
    :set line [:pick $content $lastEnd $lineEnd] ;
    :set lastEnd ( $lineEnd + 1 ) ;

#if the line is not empty (1st char is a newline) do the following
#if line is longer than 0 characters - fetch new file
#End if segment
#End do segment - while $lineEnd is smaller than the total length of the list
#End if segment
#Log completion

    :if ( [:pick $line 0 1] != "\n" ) do={
      :if ( [:len $line ] != 0 ) do={  /tool fetch mode=ftp user=**USER** password="**PASSWORD**" address=update.**SERVER**.com src-path=[:put ("~/hotspot/". $line)] dst-path=[:put ("hotspot/". $line)] } 
    } 
  } while ($lineEnd < $contentLen)
:log info "Hotspot Download Complete"

The list:
apple-icon-76x76.png
favicon.ico
apple-icon-precomposed.png
android-icon-48x48.png
ms-icon-150x150.png
apple-icon.png
favicon-96x96.png
manifest.json
json/status.html
redirect.html
android-icon-192x192.png
alogin.html
ms-icon-144x144.png
admin/login.html
ms-icon-310x310.png
android-icon-72x72.png
apple-icon-60x60.png
favicon-32x32.png
android-icon-36x36.png
apple-icon-114x114.png
status.html
apple-icon-152x152.png
apple-icon-57x57.png
apple-icon-144x144.png
errors.txt
android-icon-96x96.png
ms-icon-70x70.png
logout.html
browserconfig.xml
apple-icon-120x120.png
error.html
login.html
favicon-16x16.png
apple-icon-180x180.png
android-icon-144x144.png
apple-icon-72x72.png

Can someone take a look at the if/do/while and see what I’m missing?

:log info “Starting Hotspot Download”
:if ( [/file get [/file find name=file-list-hotspot.txt] size] > 0 ) do={
/tool fetch mode=ftp user=USER password=“PASSWORD” address=update.SERVER.com src-path=~/filelist/hotspot.txt dst-path=file-list-hotspot.txt port=21
:local content [/file get [/file find name=file-list-hotspot.txt] contents] ;
:local contentLen [ :len $content ] ;
} <----- Add this try…

#Set lineEnd to 0
#Set line to null
#Set lastEnd to 0