Corrected linked list write method