display-accts: add some input consistency checks

BUG=None
TEST=`./display-accts.py` works again

Change-Id: I8ad79e5636459ef9df6792635ed4e241137e1535
Reviewed-on: https://chromium-review.googlesource.com/733615
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
diff --git a/profiles/base/accounts/display-accts.py b/profiles/base/accounts/display-accts.py
index 9e06a74..1d519ff 100755
--- a/profiles/base/accounts/display-accts.py
+++ b/profiles/base/accounts/display-accts.py
@@ -219,6 +219,11 @@
   for f in accounts:
     try:
       content = open(f).read()
+      if not content:
+        raise ValueError('empty file')
+      if content[-1] != '\n':
+        raise ValueError('missing trailing newline')
+
       name = os.path.basename(f)
       if 'group:' in content:
         groups.append(ParseGroup(name, content))
diff --git a/profiles/base/accounts/group/dnsmasq b/profiles/base/accounts/group/dnsmasq
index e96db1b..1256afc 100644
--- a/profiles/base/accounts/group/dnsmasq
+++ b/profiles/base/accounts/group/dnsmasq
@@ -1,3 +1,3 @@
 group:dnsmasq
 gid:268
-users:dnsmasq
\ No newline at end of file
+users:dnsmasq
diff --git a/profiles/base/accounts/group/perf b/profiles/base/accounts/group/perf
index bda4731..7199b4c 100644
--- a/profiles/base/accounts/group/perf
+++ b/profiles/base/accounts/group/perf
@@ -1,3 +1,3 @@
 group:perf
 gid:205
-users:
\ No newline at end of file
+users:
diff --git a/profiles/base/accounts/group/plugdev b/profiles/base/accounts/group/plugdev
index d8bbe67..08d4934 100644
--- a/profiles/base/accounts/group/plugdev
+++ b/profiles/base/accounts/group/plugdev
@@ -1,3 +1,3 @@
 group:plugdev
 gid:46
-users:
\ No newline at end of file
+users: