Resolve nullpointer on reading file with no contents