>>38
I can see memory being an issue, but it should be rather fast to read out [j i] after you have stored all [i j]. Anyway another way I came up with quick is storing up pointers to the starts of each line and building up lines by traversing one character of each line, defaulting to ' ' once a line has been exhausted.