      subroutine words (nout, string, line, lenlin, init)

      character*(*) string, line

      last = len_trim(string)
      if (last .ne. 0) then
        loc = 1
        if (lenlin .ne. init .and. string(loc:loc) .eq. ' ')
     2           call append (' ', line, lenlin)
        do while (loc .le. last)
          next = 1

c skip over multiple spaces

          do while (next .eq. 1)
            next = index (string(loc:last), ' ')
            if (next .eq. 1) loc = loc + 1
          end do

c if no space found,

          if (next .eq. 0) next = last + 2 - loc

c truncate if too long for a full line

          next = min(next, len(line)-init)
          if (lenlin + next .ge. len(line)) then
            call putout (nout, line(:lenlin))
            line = ' '
            lenlin = init
          end if
          iend = loc + next - 2
          call append (string(loc:iend), line, lenlin)
          loc = iend + 1
          if (loc .lt. last) then
            if (string(loc:loc) .eq. ' ') then
              if (lenlin .ne. init .and. lenlin .lt. len(line))
     2               call append (' ', line, lenlin)
              loc = loc + 1
            end if
          end if
        end do
      end if
      return
      end
