Yay, it all works, thanks again. BTW, it's for this hacky script that I use when editing text files — it pads out the second part of each line starting at a particular character so that all the lines are vertically aligned on that character (probably much easier in other editors...).
function readwrite() userinput = readall(`osascript -e "display dialog \"Align on\" default answer \"#\""`) chr = chomp(last(split(userinput, ':'))) widest = 1 # read all input into array buffer = [] while !eof(STDIN) line = chomp(readline(STDIN)) chrpos = contains(line, chr) if chrpos if searchindex(line, chr) > widest widest = searchindex(line, chr) end end push!(buffer, line) end for line in buffer chrpos = contains(line, chr) if chrpos && (line != "") # chop line in two chrpos = searchindex(line, chr) firsthalf = line[1:chrpos-1] secondhalf = line[chrpos:end] newline = rpad(firsthalf, widest, " ") * secondhalf println(newline) else # don't bother println(line) end end end