Having trouble with taking data from files and giving information to another file

Whenever I run my program, It should be taking this string of information:
Shampoo 10 8.75 87.50
Pen 3 2.50 7.50
Headphones 5 20.99 104.95
MacAir 1 879.23 879.23


Raspberries 6 4.99 29.94
Oranges 5 2.79 13.95
Apples 3 3.85 11.55


from one file and outputting it to another, the finished product should look like:
Shampoo 10 8.75 87.50
Pen 3 2.50 7.50
Headphones 5 20.99 104.95
MacAir 1 879.23 879.23

cheapest item = Pen
most expensive item = MacAir
total cost = 1079.18
shopper = Mary Kay

Raspberries 6 4.99 29.94
Oranges 5 2.79 13.95
Apples 3 3.85 11.55

cheapest item = Oranges
most expensive item = Raspberries
total cost = 55.44
shopper = Winnie B. The Pooh

When I run my code however, it doesn't get past shampoo and will continue to add shampoo to the total cost infinitely. How can I change the code to produce the proper information? Thanks in advance.
CODE:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <float.h>
#include <sstream>
#include <string>
using namespace std;

ifstream input_file;
ofstream output_file;
string infilename, outfilename, itemName, lastName, firstName, name;
int quantityPurchased;
double pricePerItem, totalPrice;
double min_num = DBL_MAX;
double max_num = 0.0;
double total_cost;
istringstream isslastName, issfirstName, issName;
string maxItem, minItem;
void getName(ifstream&, string&, string&);
int main()
{

cout << "Please enter the name of the input file: ";
cin >> infilename;
cout << "Please enter the name of the output file: ";
cin >> outfilename;
input_file.open(infilename.c_str());
output_file.open(outfilename.c_str());
if (input_file.fail()){
cout << infilename << " could not be opened.\n";
return -1;
}
while(input_file >> quantityPurchased >> pricePerItem >> itemName){
while(quantityPurchased != -1){
totalPrice = pricePerItem * quantityPurchased;
output_file << left << setw(15) << itemName << " " << right << setw(3) << quantityPurchased << " " << setw(6) << setprecision(2)<< fixed << pricePerItem<< " " << setw(7) << totalPrice << endl;
total_cost += totalPrice;

if(pricePerItem <= min_num){
minItem = itemName;
min_num = pricePerItem;
}
if(pricePerItem >= max_num){
maxItem = itemName;
max_num = pricePerItem;
}
output_file << "Cheapest item: " << minItem << endl;
output_file << "Most expensive item: " << maxItem << endl;
output_file << "Total Cost: " << total_cost << endl;
}
getName(input_file, lastName, firstName);
cout<< "Shopper: " << firstName << lastName << endl;
}


return 0;
}

void getName(ifstream& file, string& lastName, string& firstName){
getline(file, lastName, ',');
getline(file, firstName);
name = firstName + lastName;
issfirstName.str(firstName);
isslastName.str(lastName);

}
For reference, this is what the output file looks like after I run my program:
Shampoo 10 8.75 87.50
Cheapest item: Shampoo
Most expensive item: Shampoo
Total Cost: 87.50
Shampoo 10 8.75 87.50
Cheapest item: Shampoo
Most expensive item: Shampoo
Total Cost: 175.00
Shampoo 10 8.75 87.50
Cheapest item: Shampoo
Most expensive item: Shampoo
Total Cost: 262.50
(this repeats constantly)
Topic archived. No new replies allowed.