The problem seems to be caused by some EOF checking using an int value of -1 in combination with (signed char) casting of the read character: If the read byte is 255 and then casted to (signed char) this equals to -1 and the function wrongly assumes EOF is reached.
The following test program
fname = 'test.txt'
file.remove(fname)
file.open(fname, 'w')
file.write(string.char(65, 66, 67, 255, 68, 69, 70))
file.close()
print(file.list()[fname] .. ' bytes written')
file.open(fname, 'r')
cont = file.read()
file.close()
print(#cont .. ' bytes read with file.read()')
print(string.byte(cont,1,-1))
gives this output:
7 bytes written
3 bytes read with file.read()
65 66 67