Fix array copy crash when beginning line exceeds number of lines.

Fixes an out of bounds exception where the number of lines (in `lines`) is lower than `beginLine`.