file writing not smooth