added write_inode function