Added write function and make file