Writes file