lab4: add writing to file