seg fault when modifying the file