Tests writing to file