Added write and read templates functionality