GPS and SD card problem

That logic is incorrect. You could have data waiting on Serial2 which makes the while statement true so then you attempt to read ss. And then you proceed to read it again inside gsp.encode.