Use with statement when writing to a file