moved P_WriteXYs inside loop