I can see a few problems here.
1. Get rid of these lines:
char* temp;
temp=new char[50];
temp[49]='\0';
delete []temp;
Explanation: variable temp is not used anywhere in the code
2. Rename iCounter to a different name in this chunk of code:
int iCounter=0;
int size=sLine.length();
while(iCounter<=size)
{
myfile<<sLine[iCounter];
iCounter++;
}
Explanation: the same variable is used in the main loop to count the number of lines
3. In the loop above (see #2), you need to change (provided you have renamed the variable to iCounter1):
while(iCounter1<size)>
Explanation: You are accessing past the address of the sLine string.
4. Just a cosmetic change: get rid of variable i. It is not used.
Other than that, I believe the program should work. Did not test it