fixing bug in alignment writing