Slight fix to writeTag