Changed error checking in writeVidModes

Improved error checking and closing null pointer problems in writeVidModes function.