Hello, this is a very strange problem. I had first put this discussion in the Linux and Unix thread, since I believe it is actually a problem with how the data is entered via but the vi editor, but I closed those out and will put it in the C thread, since it is being read with C code. Below is the code that is reading the data:

```
strcpy(passw,"P7");
fscanf(fip, "%3s", ckod); /* card # 164 */
fprintf(ff16,"\n\n%12s%12s\n", "card# 164 :", "Password ");
printf("passwd is %s\n", ckod);
if(strcmp(passw,ckod)!=0)
{
printf("\n%64s\n%80s\n", "E R R O R !", "Password is incorrect. Please resubmit.");
exit(164);
}
/***** Cards 165 - 174 *****/
fgets(str, 82, fip);
fprintf(ff16, "\nLIST OF SOLVENCY SURCHARGE RATES\n");
fgets(str, 82, fip);
if (sscanf(&str[1], "%d", &baseYearSurcharge) < 1)
{
fprintf(ff16, "Failed to correctly read the screen input for base year\n");
}
else
{
fprintf(ff16, "\nIS SURCHARGE APPLIED TO THE BASE YEAR ( YES = 1, NO = 0 ) = %d\n", baseYearSurcharge);
}
fgets(str, 82, fip);
if (sscanf(&str[1], "%lf %lf", &solvpctchkinitial, &solvpctchkmaximum) < 2)
{
fprintf(ff16, "Failed to correctly read the screen input for floor and ceiling\n");
}
else
{
fprintf(ff16, "\nINITIAL PERCENTAGE = %lf, MAXIMUM PERCENTAGE = %lf\n", solvpctchkinitial, solvpctchkmaximum);
surchargeCheckPercent = solvpctchkinitial;
}
firstLpCtr = (knri + 1)/9.0;
if ( firstLpCtr == 0 )
{
firstLpCtr = 1;
readCnt = knri + 1;
}
else
{
readCnt = 9;
}
secondLpCtr = fmod((knri + 1), 9.0);
for(i=1; i <= firstLpCtr; i++)
{
fgets( str, 82, fip);
for ( kk = 1; kk <= readCnt; kk++ )
{
if (sscanf(&str[fieldPos], "%lf", &solvsurchgrt[jj-1]) < 1)
{
fprintf(ff16, "Failed to correctly read the screen input for solvency surcharges\n");
}
else
{
fprintf(ff16, "\n SOLVENCY SURCHARGE RATE = %lf\n", solvsurchgrt[jj-1]);
fprintf(ff16, "The value of jj is %d\n", jj);
}
jj++;
fieldPos += 7;
}
fieldPos = 1;
}
if ( secondLpCtr > 0 )
{
fgets(str, 82, fip);
for ( kk = 1; kk <= secondLpCtr; kk++)
{
if (sscanf(&str[fieldPos], "%lf",&solvsurchgrt[jj-1]) < 1)
{
fprintf(ff16, "Failed to correctly read the screen input for solvency surcharges\n");
}
else
{
fprintf(ff16, "\n SOLVENCY SURCHARGE RATE = %lf\n", solvsurchgrt[jj-1]);
fprintf(ff16, "The value of jj is %d\n", jj);
}
jj++;
fieldPos += 7;
}
}
fprintf(ff16, "\n");
```

This code is reading from a data file that has much more data, including the knri value this code is using to set the loop counters. I have verified that knri is 24 in this file, knri + 1 will be 25. I have also verified that knri can never be 0, so there is no need to handle the 0 case in the code. The maximum knri + 1 can be is 81. Below is the data in my file this code is reading:

P7

1

0.005 0.007

3.150 3.050 2.900 2.850 2.700 2.600 2.550 2.450 2.300

2.150 2.050 1.900 1.800 1.650 1.500 1.400 1.250 1.150

1.050 1.000 0.900 0.850 0.750 0.700 0.650 0.000 0.000

0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000

0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000

0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000

0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000

0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000

0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000

Reading this data with the above code gives the following result:

card# 164 : Password

LIST OF SOLVENCY SURCHARGE RATES

IS SURCHARGE APPLIED TO THE BASE YEAR ( YES = 1, NO = 0 ) = 1

INITIAL PERCENTAGE = 0.005000, MAXIMUM PERCENTAGE = 0.007000

SOLVENCY SURCHARGE RATE = 3.150000

The value of jj is 1

SOLVENCY SURCHARGE RATE = 3.050000

The value of jj is 2

SOLVENCY SURCHARGE RATE = 2.900000

The value of jj is 3

SOLVENCY SURCHARGE RATE = 2.850000

The value of jj is 4

SOLVENCY SURCHARGE RATE = 0.000000

The value of jj is 5

SOLVENCY SURCHARGE RATE = 0.000000

The value of jj is 6

SOLVENCY SURCHARGE RATE = 600.000000

The value of jj is 7

SOLVENCY SURCHARGE RATE = 0.550000

The value of jj is 8

SOLVENCY SURCHARGE RATE = 2.450000

The value of jj is 9

SOLVENCY SURCHARGE RATE = 3.150000

The value of jj is 10

SOLVENCY SURCHARGE RATE = 3.050000

The value of jj is 11

SOLVENCY SURCHARGE RATE = 2.900000

The value of jj is 12

SOLVENCY SURCHARGE RATE = 2.850000

The value of jj is 13

SOLVENCY SURCHARGE RATE = 0.000000

The value of jj is 14

SOLVENCY SURCHARGE RATE = 0.000000

The value of jj is 15

SOLVENCY SURCHARGE RATE = 600.000000

The value of jj is 16

SOLVENCY SURCHARGE RATE = 0.550000

The value of jj is 17

SOLVENCY SURCHARGE RATE = 2.450000

The value of jj is 18

SOLVENCY SURCHARGE RATE = 3.150000

The value of jj is 19

SOLVENCY SURCHARGE RATE = 3.050000

The value of jj is 20

SOLVENCY SURCHARGE RATE = 2.900000

The value of jj is 21

SOLVENCY SURCHARGE RATE = 2.850000

The value of jj is 22

SOLVENCY SURCHARGE RATE = 0.000000

The value of jj is 23

SOLVENCY SURCHARGE RATE = 0.000000

The value of jj is 24

SOLVENCY SURCHARGE RATE = 600.000000

The value of jj is 25

The first line of output indiecates that the password was sucessfully read. Note that the next two lines are read and processed without a problem, and then it starts to go haywire. Moving the sscanf pointer by seven should put it at the start of the next field, and does for the first four fields in the line. Why it gets lost in the remaining five fields, I do not understand. Also, fgets starts reading the same line over and over, and I don't know why that is happening. I still feel that there is something wrong with how the data is entered in the vi editor. Note that it has has been verified that the lines are space filled between the fields, the lines are 80 columns long( space filled ), and there is a line feed at the end of each line. Any help with this is greatly appreciated.