Hello, I am new to C++ and programming in general and am having a problem with a word unscrambler I'm trying to code. I have two txt files, words.txt and wordlist.txt that contain the scrambled words and unscrambled words respectively. As a test, my scrambled word is tac and my wordlist contains: dog bark cat. It finds the right word, but it has trouble unscrambling it.

Code:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
int main()
{
	fstream list("wordlist.txt");
	fstream words("words.txt");
	string sWords, sList;
	getline(words, sWords);
	while(!list.eof())
	{
		getline(list,sList);
		if(sWords.length()==sList.length())
		{
			for(int i=0; i<sWords.length();i++){
				for(int k=0; k<sList.length();k++){
					if(sWords[i]==sList[k]){
						sWords[i]=sList[k];
					}
				}
			}
		}
		cout << sWords << endl;
		getline(words, sWords);
	}
	cin.get();
	return 0;
}
My output is:
Code:
tac
tac
tac
tac
... loops for a while >_>
I've been trying for a long time and am wondering if someone could point me in the right direction. Thanks