What do you want to do? Do you want to sort the elements in the file as follows?
Input file "a"
5
3
2
4
1
Output file "a"
1
2
3
4
5
Also in your present code,
1 2 3 4 5 6 7
while( fin ) // fin is not a boolean expression
{
fin>>i; // Only the last element read from the file shall be stored in i.
// All the previous elements read shall be overwritten.
l++;
}