The function readByteFromSerial is unknown (No results found for readByteFromSerial site:Arduino Reference - Arduino Reference), so it might contain the error, but this looks sus:
byte buff[1024];
int len = readByteFromSerial(buff, 1024);
if (len > 0) {
len = 0;
f.write(buff, 1023)
Read up to 1024 bytes, write up to 1023...
Pogo