also the first fin>>temp;
can make a problem if the file contains only 4 values...