The return value from fwrite was being checked against the size of the data rather than the number of bytes written. This caused node.compile() to falsely return failure.