Fixing line ending anomalies