Checked text file was open before writing to it.