Use parser flags instead of regexp matching
Wrap line
Do not assign inside if statement
Calculate file path just once
Use foreach instead of for