Problems implementing write function of a character device