Im sorry but I thought this was a beginners forum...
well, yes. But most beginners here are asking 'how you loop to print every other number' not 'how to do networking'.
Even so, its fine, but we still need to know as much as you can feed us about the problem. Networking is not just code, unlike that print loop; it is a combination of code and your computer setup. If for example you try to open an ip address that cannot be resolved from your computer, no amount of debugging or coding is going to fix that.
you get 14 strings, 14 full lines of text, in a loop, discarding the first 13 of them:
for (int i = 1; i <= 15; i++)
std::cout << ip << '\n';
that may be correct if the file has 13 lines of junk that you do not want. but you need to tell us that.
what does the cout provide? Is it the correct value there? I recommend splitting the file reader and the networking stuff apart, but for now lets get it working.
if you want to check the IP address, you can cheat and just say
string cmd = "ping " + ip;