Fix timestamp writing