Found the problem! And (re)learned about char arrays! The problem was that the char array where I was storing my values wasn't large enough. I read in five values, \n (line break), followed by a four digit position. The char array was only size five, but char arrays always need to be one larger than you think because the last character has to be \0. So the last digit I read in was getting thrown away. I changed the array size to 6, and it worked!
Thanks all for the help, and always make your char arrays larger than you think!