More range aproach, untested written on the fly from mobile phone import std.stdio : File; import std.range : chunks; import.std.algorithm : map, filter, array;
void main() { auto r = File("text.txt").byLine .filter!(a=>a.length) .chunks(2) .map!(a=>[a[0].dup, a[1].dup]) .array; writeln(r); }