Code:for (j=0; j<j+1; j++) { fscanf(ifp, "%d%d%d%lf", &month, &day, &year, &temp); if (month = wedMonth) { daysInMonth++; sumMonthly += temp; } if (day == wedDay && month == wedMonth) { numDays++; sumDays += temp; } else if (day == -1) break; } fclose(ifp); return 0; } My loop was working fine before I added the first if statement to the begginning. Without that first if statement, it works.