Changed to write to a file instead