My program takes data and plots the coresponding time and value. For some reason when it starts at zero, it takes the last data value and makes that the data point from time 0 to time next data value is recorded.
Your True case (String from shift register = " END") appends 0 to the X- and Y-arrays. That adds a point that is back at the start.
A generally better way: Initialize the arrays outside the loop. (Use NaN for non-data - it does not show up on plots). Pass them to shift registers. In the False case use replace array subset to insert the new values. In the True case pass tha arrays through unchanged. Use a third shift register to keep track of the index to replace.