Implemented writeBytesToFile function.