diff --git a/Doc/changelog.docu b/Doc/changelog.docu
index b497a8b6..4f12db85 100644
--- a/Doc/changelog.docu
+++ b/Doc/changelog.docu
@@ -27,6 +27,7 @@
PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)
PLY Reader: Fixed endless loop on unknown property list type
PLY Reader: Fix hang when reading directly from istream (Thanks to Paul Loré for the patch)
+PLY Reader: Fix file load for ASCII PLY without a newline at the end of the file (Thanks to Mathieu Lamarre for the patch )
OM Writer/Reader: Update file format version to 2.0. Older files can still be read, but older OpenMesh versions cannot read new format.
OM Writer/Reader: Fixed inconsistent writing/reading of edge properties
OM Writer/Reader: Add option to store status
diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc
index 1b35d53d..4617afe9 100644
--- a/src/OpenMesh/Core/IO/reader/PLYReader.cc
+++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc
@@ -306,6 +306,14 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
for (std::vector::iterator e_it = elements_.begin(); e_it != elements_.end(); ++e_it)
{
+ if (_in.eof()) {
+ if (err_enabled)
+ omerr().enable();
+
+ omerr() << "Unexpected end of file while reading." << std::endl;
+ return false;
+ }
+
if (e_it->element_== VERTEX)
{
// read vertices:
@@ -475,14 +483,6 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
}
}
- if (_in.eof()) {
- if (err_enabled)
- omerr().enable();
-
- omerr() << "Unexpected end of file while reading." << std::endl;
- return false;
- }
-
if(e_it->element_== FACE)
// stop reading after the faces since additional elements are not preserved anyway
break;