Fix reading sequences: Allocate array before writing to it