Maze write() function working as intended