[solved]Problem with Serial Communication on Leonardo

In my opinion, the Leonardo is specifically for USB emulation. The Uno is still the most common board to start with.

You test if something is available (in the buffer), but you don't read it. So if some data is in the buffer, it is always available.
You must read the data from the buffer, so the avaible function will return zero if the buffer is empty.

Read about the functions and look at the examples: