SoftwareSerial resets arduino pro mini

In my opinion you should use a "bloking" condition before every read()

Example:
While serial.available()==0{}

It would block your code until there are data coming from your serial device
I also suggest to add a timeout, if you need more help write