I am making a program with file I/O. How can I tell if a file exists before I write over it? (preferably non-Windows, but post that if it's the only way)

Thanks