nit: better check would be if (!contents) so that it checks for null / undefined as well.