Okay - I think that I know where you are going wrong. If you have had any success then you were lucky - your code will not be reliable. I suspect that you are using
this tutorial which is very old (2011).
Let us look at FTP download first. When you run the statement ...
ftp.downloadfile(...., ...., ...., ....)
the download operation will begin. It will run asynchronously, which means that you B4A code will continue on to the following statement while the download is still in progress. If you try to read the downloaded file before the download has finished then you will see rubbish - that is what I think is happening. If there is a delay before you read the file, such as waiting for a button press, then you may be lucky and catch the file after the download is complete. But to be sure that your code will work reliably then you have to check that the download is complete before you try to read the file. The two most common ways to detect that the download operation is complete are to use a "Wait For ..." resumable sub, or put a switch in the "download complete" event. Your code samples do not show either of these, but you are still not showing very much code. The tutorial that I think you are using does not make this very clear either.
If this seems to describe your problem then let me know and I will try to give you some more guidance.