Serial Programming question

cyberhawk9:
I thought inserting
if(Serial1.available()) before data=Serial1.read() would tell arduino to wait until the next byte is available.

You seem to be under the impression that Serial communication is fast; It's not. The second

if(Serial1.available())

will happen eons before the next serial byte is received. You either need to make it blocking, implement a state machine with some sort of end of packet marker and a buffer to store all of the data, or check for more than one byte is available the first time.