A common problem for people writing PC programs to communicate with the Arduino is not allowing enough time for the Arduino to reset after the serial port is opened. A simple way to do this is to have the Arduino send a short message from setup() such as Serial.println("Ready"); and for the PC to wait until it receives that before doing anything else.
Another common problem is when the PC program briefly opens the serial port, sends something and closes the port. Next time the port is opened the Arduino will reset again. The PC program should open the port and keep it open until it is completely finished with the Arduino.
This demo written in Python illustrates what I am saying. The principle is the same in any language.