Stop sending data on EOF?

Hi...i try to send a text file to my local server where i put a php file to insert the data to a database. I have a problem with the code, its loop forever and keep sending the same data over and over.
Here is my code

/*
 * Example of getline from section 27.7.1.3 of the C++ standard
 * Demonstrates the behavior of getline for various exceptions.
 * See http://www.cplusplus.com/reference/iostream/istream/getline/
 *
 * Note: This example is meant to demonstrate subtleties the standard and
 * may not the best way to read a file.
 */
#include <SdFat.h>
#include <stdlib.h>
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 
  0x90, 0xA2, 0xDA, 0x0D, 0xD2, 0xC2 };
IPAddress ip(192,168,0,3);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
IPAddress server(192,168,0,5);
EthernetClient client;
boolean SDavailable;
char inChar;
int connectLoop;

// SD chip select pin
const uint8_t chipSelect = 4;

// file system object
SdFat sd;

// create a serial stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
void setup(void) {
  Serial.begin(9600);
  // disable w5100
  pinMode(10,OUTPUT);
  pinMode(4, OUTPUT);

  digitalWrite(10, LOW); //ethernet on
  digitalWrite(4, HIGH); //SD card off
  Ethernet.begin(mac, ip, gateway);

  Serial.print("Starting SD...");
  digitalWrite(10, HIGH);
  digitalWrite(4, LOW);

  // pstr stores strings in flash to save RAM
  //cout << pstr("Type any character to start\n");
  //while (Serial.read() <= 0) {}
  delay(400);  // catch Due reset problem

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

  // make the test file
  //makeTestFile();

  // run the example
  //cout << "\nDone!\n";
}
//------------------------------------------------------------------------------
void loop(void) {
  const int line_buffer_size = 60;
  char netBuffer[line_buffer_size];
  ifstream sdin("test.TXT");
  int line_number = 0;

  while (sdin.getline(netBuffer, line_buffer_size, '\n') || sdin.gcount()) {
    int count = sdin.gcount();
    if (sdin.fail()) {
      cout << "Partial long line";
      sdin.clear(sdin.rdstate() & ~ios_base::failbit);
    } else if (sdin.eof()) {
      cout << "Partial final line";  // sdin.fail() is false
    } else {
      count--;  // Don’t include newline in count
      cout << "Line " << ++line_number;
    }
    digitalWrite(10, LOW);
        digitalWrite(4, HIGH);
        if(client.connect(server, 80))
        {  
          client.print("GET /arduino/insert2.php?netBuffer=");
          client.print(netBuffer);
          client.println(" HTTP/1.1");
          client.print("Host: ");
          client.println(server);
          client.println("Connection: close\r\n");

          // read server response    
          while(client.connected())
          {
            while(client.available())
            {
              inChar = client.read();
              Serial.write(inChar);
              // set connectLoop to zero if a packet arrives
              connectLoop = 0;
            }
            connectLoop++;

            // if more than 10000 milliseconds since the last packet
            if(connectLoop > 10000)
            {
              // then close the connection from this end.
              Serial.println();
              Serial.println(F("Timeout"));
              client.stop();
            }
            // this is a delay for the connectLoop timing
            delay(1);
          }
          Serial.println();
          Serial.println(F("disconnecting."));
          // close client end
          client.stop();
          //client.flush(); 
        }
        else
        {
          Serial.println("connection failure");
        }
      }
  }

How can i stop sending the data to server once eof/end of file is detected and wait until a new line is available and send it. This is for data logger which i want to log some data to sd card and once client is available, read the file and send to server. if client not available only write to sd card.
The program flow i want to achieve is :

  1. log data to test.txt on sd card (this is loop forever)
  2. if client available, open and read test.txt then send to server until eof
  3. if eof but client is still available, then wait until a new line is writen then read and send it to server.
  4. If client not available, remember last record sent.
  5. if client available again, continue sending data from the last record sent.
    the code above is only to read and send data to server which still has an error. I plan to assembly the code once the code above is working.

Don't open a new thread on the same problem, while continuing to ask questions in the old one.