Bollocks. Number of lines also changes within the loop so had to be moved back