Fix IO error when transferring file other than txt