Added checking for file selection.