The problem is that
write() behave differently when you give them numerical data, such as a byte.
When you pass your byte to
print(), it converts it to text which is convenient for humans to read. For example:
byte b = 10;
This will result in the following ASCII characters being written to the file:
That's actually two bytes: one byte with the value 49, which represents ASCII character
1, followed by a byte with the value 48 representing character
write() does not convert numbers into text. It writes them in their raw binary form. For example:
byte b = 10;
When you do this, it doesn't write a "1" and a "0" to the file. It literally writes a binary byte with the value 10. When you try to open this as a text file, your computer interprets that byte as a single ASCII character. It so happens that ASCII value 10 is the newline character, meaning your file basically contains a blank line.
For comparison, try this instead:
byte b = 65;
ASCII value 65 corresponds to the letter
A (uppercase), so that's what you should see in the file.
write() functions are useful for writing raw data to file in the most efficient form for another machine to read (as opposed to being human-readable). This is why they allow you to write arrays -- it acts like one big block of raw data with a fixed format.
In your case,
print() is more appropriate. That means for outputting arrays of numbers, you will need to use loops. That functionality isn't built-in to the
print() functions because different projects might need different formatting. For example, some people might want one number per line, whereas others might want numbers separated by commas, and so on.