Make validateFile() consistent with other validate* functions.

This commit does the following things to make validateFile() more
consistent and easier to test:

1. Return (success, errmsg) in validateFile().
2. Print error message in main function instead of in validateFile()
3. Add unit test for validateFile().