I've already got 10 WA, can anybody tell me what I'm missing? Any special cases? HELP, PLEASE...

[cpp]#include <iostream>
#include <string>
#include <fstream>
#include <ctype.h>
#include <vector>
#include <map>
using namespace std;
map < string, vector < long > > index;
vector < long > empty;
string s;
long t;
int main(){
// ifstream cin("in.txt");
t = 1;
while(getline(cin, s)){
index.clear();
while(s.size()){ // storing index words
for(unsigned i = 0; i < s.size(); i++) s[i] = toupper(s[i]);
index[s] = empty;
getline(cin, s);
}
long cnt = 0;
while(getline(cin, s) && s.size() && ++cnt){ // inserting to index lines of word that match
s += ' ';
string word = "";
for(unsigned i = 0; i < s.size(); i++){
s[i] = toupper(s[i]);
if(isalnum(s[i])) word += s[i];
else{
if(index.find(word) != index.end() && (!index[word].size() || index[word].back() != cnt))
index[word].push_back(cnt);
word = "";
}
}
}
cout << "Case " << t++ << endl; // starting to print answer
for(map < string, vector < long > > :: iterator it = index.begin(); it != index.end(); it++)
if(it->second.size()){
cout << it->first;
for(unsigned i = 0; i < it->second.size(); i++){
if(i + 1 == it->second.size() || it->second[i] + 1 != it->second[i + 1]){
cout << " " << it->second[i];
if(i + 1 != it->second.size()) cout << ",";
}else{
long st = i;
while(i + 1 < it->second.size() && it->second[i] + 1 == it->second[i + 1]) i++;
cout << " " << it->second[st] << "-" << it->second[i];
if(i + 1 != it->second.size()) cout << ",";
}
}
cout << endl;
}
cout << endl;
}
return 0;
}
[/cpp]