Fixing crash when lines are being written while scrolling up