Is my code fine in the areas of read and write? What:

This is a code that when executed simply writes packet to certain file types. Packet is very simple and contains things like: 

description, partCount, price...


Please:


Ignore the usage of namespace std; as this is for educational
purposes, mostly. It will most likely not be reproduced in a real
program.
Focus on reviewing the read and write portions as I would love
feedback on those portions.
I used some other things for simplicity, but in general I am mainly
looking for feedback on read/write portions of the code.


Intent:

I'm specifically looking for feedback on the read and write portions of the code. Could I get feedback on it as well as is it feasible as a piece of code and what can I improve on/etc.???

Main.cpp:

#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;vector&gt;

#include "Packet.h"

using namespace std;

int main() {
    cout &lt;&lt; "----------------------------------------------------" &lt;&lt; endl;
    cout &lt;&lt; "Input and Output Filing System" &lt;&lt; endl;
    cout &lt;&lt; "----------------------------------------------------" &lt;&lt; endl;
    ifstream inFile;
    ofstream outFile;
    fstream bOutFile;
    vector&lt;Packet&gt; package;
    Packet one(0, "A packet of cheese.", 21.99, 4);
    package.push_back(one);
    Packet two(1, "A packet of super-cheese.", 31.99, 2);
    package.push_back(two);

    cout &lt;&lt; "Starting to write packets to file..." &lt;&lt; endl;

    outFile.open("Insert Your Destination of File Here.Txt");
    for (int i = 0; i &lt; package.size(); ++i) {
        outFile &lt;&lt; "{" &lt;&lt; endl;
        outFile &lt;&lt; package[i].getPartId() &lt;&lt; "," &lt;&lt; endl;
        outFile &lt;&lt; package[i].getDescription() &lt;&lt; "," &lt;&lt; endl;
        outFile &lt;&lt; package[i].getPartCount() &lt;&lt; "," &lt;&lt; endl;
        outFile &lt;&lt; package[i].getPrice() &lt;&lt; "," &lt;&lt; endl;
        outFile &lt;&lt; "}" &lt;&lt; endl &lt;&lt; endl;
    }
    outFile.close();

    cout &lt;&lt; "Starting to read packets from file..." &lt;&lt; endl;

    inFile.open("Insert Your Destination of File Here.Txt");
    string line;
    while (getline(inFile, line)) {
        if (line[0] != '{' &amp;&amp; line[0] != '}') {
            cout &lt;&lt; line.substr(0, line.size() - 1) &lt;&lt; endl;
        }
    }
    inFile.close();

    cout &lt;&lt; "Starting to write packets to binary..." &lt;&lt; endl;

    bOutFile.open("Insert Your Destination of File Here.bin", ios::out | ios::binary);
    for (int i = 0; i &lt; package.size(); ++i) {
        bOutFile.write((char*)&amp;package[i], sizeof(package[i]));
    }
    bOutFile.close();

    system("pause");
}


Packet.h:

#pragma once
#include &lt;string&gt;

using namespace std;

class Packet {
public:
    Packet(int partId, string description, double price, int partCount) :
        partId(partId), description(description), price(price), partCount(partCount) {}
    int getPartId() const { return partId; }
    string getDescription() const { return description; }
    double getPrice() const { return price; }
    int getPartCount() const { return partCount; }

private:
    int partId;
    string description;
    double price;
    int partCount;
};
for (int i = 0; i &lt; package.size(); ++i)


I'd use for (auto&amp; p : package) instead if the index (i) is not used for anything.

outFile &lt;&lt; package[i].getPartId() &lt;&lt; "," &lt;&lt; endl;


Remember that std::endl flushes the stream. This is very minor, but I'd use a manual '\n' and then flush when the whole object is written.

bOutFile.write((char*)&amp;package[i], sizeof(package[i]));


This is I do not like at all. Copying objects like this is problematic when you have objects with more complex data. I.e. pointers or dynamically allocated memory.

Take a look at serialization/deserialization, I found this read quite good concerning the topic: https://rubentorresbonet.wordpress.com/2014/08/25/an-overview-of-data-serialization-techniques-in-c/

Packet(int partId, string description, double price, int partCount


Make the passed arguments const references instead! (Otherwise an extra copy will be done)