Not sure what the problem is. The document length pixel was accidentally in the for loop. Shouldnt have broken it, but definitely not right